Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
a1070e4f
Unverified
Commit
a1070e4f
authored
Dec 11, 2020
by
Todd Volkert
Committed by
GitHub
Dec 11, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Remove duplicate code in Element.rebuild() and BuildOwner.buildScope() (#71940)" (#72120)
This reverts commit
c8f07aad
.
parent
8df56056
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
93 deletions
+30
-93
pointer_router.dart
packages/flutter/lib/src/gestures/pointer_router.dart
+0
-1
framework.dart
packages/flutter/lib/src/widgets/framework.dart
+30
-54
framework_test.dart
packages/flutter/test/widgets/framework_test.dart
+0
-38
No files found.
packages/flutter/lib/src/gestures/pointer_router.dart
View file @
a1070e4f
...
@@ -75,7 +75,6 @@ class PointerRouter {
...
@@ -75,7 +75,6 @@ class PointerRouter {
///
///
/// This is valid in debug builds only. In release builds, this will throw an
/// This is valid in debug builds only. In release builds, this will throw an
/// [UnsupportedError].
/// [UnsupportedError].
@visibleForTesting
int
get
debugGlobalRouteCount
{
int
get
debugGlobalRouteCount
{
int
?
count
;
int
?
count
;
assert
(()
{
assert
(()
{
...
...
packages/flutter/lib/src/widgets/framework.dart
View file @
a1070e4f
...
@@ -2651,26 +2651,6 @@ class BuildOwner {
...
@@ -2651,26 +2651,6 @@ class BuildOwner {
/// Only valid when asserts are enabled.
/// Only valid when asserts are enabled.
bool
get
debugBuilding
=>
_debugBuilding
;
bool
get
debugBuilding
=>
_debugBuilding
;
bool
_debugBuilding
=
false
;
bool
_debugBuilding
=
false
;
/// The element currently being built, or null if no element is actively
/// being built.
///
/// This is valid in debug builds only. In release builds, this will throw an
/// [UnsupportedError].
@visibleForTesting
Element
?
get
debugCurrentBuildTarget
{
Element
?
result
;
bool
isSupportedOperation
=
false
;
assert
(()
{
result
=
_debugCurrentBuildTarget
;
isSupportedOperation
=
true
;
return
true
;
}());
if
(
isSupportedOperation
)
{
return
result
;
}
throw
UnsupportedError
(
'debugCurrentBuildTarget is not supported in release builds'
);
}
Element
?
_debugCurrentBuildTarget
;
Element
?
_debugCurrentBuildTarget
;
/// Establishes a scope in which calls to [State.setState] are forbidden, and
/// Establishes a scope in which calls to [State.setState] are forbidden, and
...
@@ -2696,25 +2676,6 @@ class BuildOwner {
...
@@ -2696,25 +2676,6 @@ class BuildOwner {
assert
(
_debugStateLockLevel
>=
0
);
assert
(
_debugStateLockLevel
>=
0
);
}
}
void
_runWithCurrentBuildTarget
(
Element
element
,
VoidCallback
callback
)
{
assert
(
_debugStateLocked
);
Element
?
debugPreviousBuildTarget
;
assert
(()
{
debugPreviousBuildTarget
=
_debugCurrentBuildTarget
;
_debugCurrentBuildTarget
=
element
;
return
true
;
}());
try
{
callback
();
}
finally
{
assert
(()
{
assert
(
_debugCurrentBuildTarget
==
element
);
_debugCurrentBuildTarget
=
debugPreviousBuildTarget
;
return
true
;
}());
}
}
/// Establishes a scope for updating the widget tree, and calls the given
/// Establishes a scope for updating the widget tree, and calls the given
/// `callback`, if any. Then, builds all the elements that were marked as
/// `callback`, if any. Then, builds all the elements that were marked as
/// dirty using [scheduleBuildFor], in depth order.
/// dirty using [scheduleBuildFor], in depth order.
...
@@ -2757,22 +2718,26 @@ class BuildOwner {
...
@@ -2757,22 +2718,26 @@ class BuildOwner {
try
{
try
{
_scheduledFlushDirtyElements
=
true
;
_scheduledFlushDirtyElements
=
true
;
if
(
callback
!=
null
)
{
if
(
callback
!=
null
)
{
_runWithCurrentBuildTarget
(
context
,
()
{
assert
(
_debugStateLocked
);
Element
?
debugPreviousBuildTarget
;
assert
(()
{
context
.
_debugSetAllowIgnoredCallsToMarkNeedsBuild
(
true
);
debugPreviousBuildTarget
=
_debugCurrentBuildTarget
;
_debugCurrentBuildTarget
=
context
;
return
true
;
}());
_dirtyElementsNeedsResorting
=
false
;
try
{
callback
();
}
finally
{
assert
(()
{
assert
(()
{
context
.
_debugSetAllowIgnoredCallsToMarkNeedsBuild
(
true
);
context
.
_debugSetAllowIgnoredCallsToMarkNeedsBuild
(
false
);
assert
(
_debugCurrentBuildTarget
==
context
);
_debugCurrentBuildTarget
=
debugPreviousBuildTarget
;
_debugElementWasRebuilt
(
context
);
return
true
;
return
true
;
}());
}());
_dirtyElementsNeedsResorting
=
false
;
}
try
{
callback
();
}
finally
{
assert
(()
{
context
.
_debugSetAllowIgnoredCallsToMarkNeedsBuild
(
false
);
_debugElementWasRebuilt
(
context
);
return
true
;
}());
}
});
}
}
_dirtyElements
.
sort
(
Element
.
_sort
);
_dirtyElements
.
sort
(
Element
.
_sort
);
_dirtyElementsNeedsResorting
=
false
;
_dirtyElementsNeedsResorting
=
false
;
...
@@ -4404,7 +4369,19 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
...
@@ -4404,7 +4369,19 @@ abstract class Element extends DiagnosticableTree implements BuildContext {
return
true
;
return
true
;
}());
}());
assert
(
_lifecycleState
==
_ElementLifecycle
.
active
);
assert
(
_lifecycleState
==
_ElementLifecycle
.
active
);
owner
!.
_runWithCurrentBuildTarget
(
this
,
performRebuild
);
assert
(
owner
!.
_debugStateLocked
);
Element
?
debugPreviousBuildTarget
;
assert
(()
{
debugPreviousBuildTarget
=
owner
!.
_debugCurrentBuildTarget
;
owner
!.
_debugCurrentBuildTarget
=
this
;
return
true
;
}());
performRebuild
();
assert
(()
{
assert
(
owner
!.
_debugCurrentBuildTarget
==
this
);
owner
!.
_debugCurrentBuildTarget
=
debugPreviousBuildTarget
;
return
true
;
}());
assert
(!
_dirty
);
assert
(!
_dirty
);
}
}
...
@@ -5609,7 +5586,6 @@ abstract class RenderObjectElement extends Element {
...
@@ -5609,7 +5586,6 @@ abstract class RenderObjectElement extends Element {
}
}
@override
@override
@mustCallSuper
void
performRebuild
()
{
void
performRebuild
()
{
assert
(()
{
assert
(()
{
_debugDoingBuild
=
true
;
_debugDoingBuild
=
true
;
...
...
packages/flutter/test/widgets/framework_test.dart
View file @
a1070e4f
...
@@ -1494,44 +1494,6 @@ void main() {
...
@@ -1494,44 +1494,6 @@ void main() {
expect
(
GestureBinding
.
instance
!.
pointerRouter
.
debugGlobalRouteCount
,
pointerRouterCount
);
expect
(
GestureBinding
.
instance
!.
pointerRouter
.
debugGlobalRouteCount
,
pointerRouterCount
);
expect
(
RawKeyboard
.
instance
.
keyEventHandler
,
same
(
rawKeyEventHandler
));
expect
(
RawKeyboard
.
instance
.
keyEventHandler
,
same
(
rawKeyEventHandler
));
});
});
testWidgets
(
'Errors in build'
,
(
WidgetTester
tester
)
async
{
final
ErrorWidgetBuilder
oldErrorBuilder
=
ErrorWidget
.
builder
;
ErrorWidget
.
builder
=
(
FlutterErrorDetails
detail
)
=>
throw
AssertionError
();
try
{
final
FlutterExceptionHandler
?
oldErrorHandler
=
FlutterError
.
onError
;
FlutterError
.
onError
=
(
FlutterErrorDetails
detail
)
{};
try
{
int
buildCount
=
0
;
void
handleBuild
()
=>
buildCount
++;
expect
(
tester
.
binding
.
buildOwner
!.
debugCurrentBuildTarget
,
isNull
);
await
tester
.
pumpWidget
(
_WidgetThatCanThrowInBuild
(
onBuild:
handleBuild
));
expect
(
buildCount
,
1
);
await
tester
.
pumpWidget
(
_WidgetThatCanThrowInBuild
(
onBuild:
handleBuild
,
shouldThrow:
true
));
tester
.
takeException
();
expect
(
buildCount
,
2
);
expect
(
tester
.
binding
.
buildOwner
!.
debugCurrentBuildTarget
,
isNull
);
}
finally
{
FlutterError
.
onError
=
oldErrorHandler
;
}
}
finally
{
ErrorWidget
.
builder
=
oldErrorBuilder
;
}
});
}
class
_WidgetThatCanThrowInBuild
extends
StatelessWidget
{
const
_WidgetThatCanThrowInBuild
({
required
this
.
onBuild
,
this
.
shouldThrow
=
false
});
final
VoidCallback
onBuild
;
final
bool
shouldThrow
;
@override
Widget
build
(
BuildContext
context
)
{
onBuild
();
assert
(!
shouldThrow
);
return
Container
();
}
}
}
class
_FakeFocusManager
implements
FocusManager
{
class
_FakeFocusManager
implements
FocusManager
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment