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
48bb12df
Unverified
Commit
48bb12df
authored
Mar 27, 2023
by
Michael Goderbauer
Committed by
GitHub
Mar 27, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make Element tree root generic (#123352)
Make Element tree root generic
parent
66e6acbe
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
95 additions
and
55 deletions
+95
-55
all_elements_bench.dart
...ks/microbenchmarks/lib/foundation/all_elements_bench.dart
+4
-4
smoke_test.dart
dev/integration_tests/flutter_gallery/test/smoke_test.dart
+1
-1
fix_widgets.yaml
packages/flutter/lib/fix_data/fix_widgets/fix_widgets.yaml
+11
-0
binding.dart
packages/flutter/lib/src/widgets/binding.dart
+28
-20
framework.dart
packages/flutter/lib/src/widgets/framework.dart
+20
-5
widget_inspector.dart
packages/flutter/lib/src/widgets/widget_inspector.dart
+4
-4
fast_reassemble_test.dart
packages/flutter/test/widgets/fast_reassemble_test.dart
+5
-5
memory_allocations_test.dart
packages/flutter/test/widgets/memory_allocations_test.dart
+1
-1
run_app_async_test.dart
packages/flutter/test/widgets/run_app_async_test.dart
+2
-2
widget_inspector_test.dart
packages/flutter/test/widgets/widget_inspector_test.dart
+3
-3
widget_inspector_test_utils.dart
...ges/flutter/test/widgets/widget_inspector_test_utils.dart
+2
-2
widgets.dart
packages/flutter/test_fixes/widgets/widgets.dart
+3
-0
widgets.dart.expect
packages/flutter/test_fixes/widgets/widgets.dart.expect
+3
-0
memory_allocations_test.dart
...flutter/test_release/widgets/memory_allocations_test.dart
+1
-1
_matchers_web.dart
packages/flutter_test/lib/src/_matchers_web.dart
+1
-1
binding.dart
packages/flutter_test/lib/src/binding.dart
+2
-2
controller.dart
packages/flutter_test/lib/src/controller.dart
+1
-1
finders.dart
packages/flutter_test/lib/src/finders.dart
+1
-1
widget_tester.dart
packages/flutter_test/lib/src/widget_tester.dart
+2
-2
No files found.
dev/benchmarks/microbenchmarks/lib/foundation/all_elements_bench.dart
View file @
48bb12df
...
...
@@ -56,19 +56,19 @@ Future<void> main() async {
final
Stopwatch
watch
=
Stopwatch
();
print
(
'flutter_test allElements benchmark... (
${WidgetsBinding.instance.r
enderView
Element}
)'
);
print
(
'flutter_test allElements benchmark... (
${WidgetsBinding.instance.r
oot
Element}
)'
);
// Make sure we get enough elements to process for consistent benchmark runs
int
elementCount
=
collectAllElementsFrom
(
WidgetsBinding
.
instance
.
r
enderView
Element
!,
skipOffstage:
false
).
length
;
int
elementCount
=
collectAllElementsFrom
(
WidgetsBinding
.
instance
.
r
oot
Element
!,
skipOffstage:
false
).
length
;
while
(
elementCount
<
2458
)
{
await
Future
<
void
>.
delayed
(
Duration
.
zero
);
elementCount
=
collectAllElementsFrom
(
WidgetsBinding
.
instance
.
r
enderView
Element
!,
skipOffstage:
false
).
length
;
elementCount
=
collectAllElementsFrom
(
WidgetsBinding
.
instance
.
r
oot
Element
!,
skipOffstage:
false
).
length
;
}
print
(
'element count:
$elementCount
'
);
watch
.
start
();
for
(
int
i
=
0
;
i
<
_kNumIters
;
i
+=
1
)
{
final
List
<
Element
>
allElements
=
collectAllElementsFrom
(
WidgetsBinding
.
instance
.
r
enderView
Element
!,
WidgetsBinding
.
instance
.
r
oot
Element
!,
skipOffstage:
false
,
).
toList
();
allElements
.
clear
();
...
...
dev/integration_tests/flutter_gallery/test/smoke_test.dart
View file @
48bb12df
...
...
@@ -78,7 +78,7 @@ Future<void> smokeDemo(WidgetTester tester, GalleryDemo demo) async {
// Verify that the dumps are pretty.
final
String
routeName
=
demo
.
routeName
;
verifyToStringOutput
(
'debugDumpApp'
,
routeName
,
WidgetsBinding
.
instance
.
r
enderView
Element
!.
toStringDeep
());
verifyToStringOutput
(
'debugDumpApp'
,
routeName
,
WidgetsBinding
.
instance
.
r
oot
Element
!.
toStringDeep
());
verifyToStringOutput
(
'debugDumpRenderTree'
,
routeName
,
RendererBinding
.
instance
.
renderView
.
toStringDeep
());
verifyToStringOutput
(
'debugDumpLayerTree'
,
routeName
,
RendererBinding
.
instance
.
renderView
.
debugLayer
?.
toStringDeep
()
??
''
);
...
...
packages/flutter/lib/fix_data/fix_widgets/fix_widgets.yaml
View file @
48bb12df
...
...
@@ -23,6 +23,17 @@
# * ListWheelScrollView: fix_list_wheel_scroll_view.yaml
version
:
1
transforms
:
# Changes made in https://github.com/flutter/flutter/pull/123352
-
title
:
"
Migrate
to
'rootElement'"
date
:
2023-03-13
element
:
uris
:
[
'
widgets.dart'
,
'
material.dart'
,
'
cupertino.dart'
]
field
:
'
renderViewElement'
inClass
:
'
WidgetsBinding'
changes
:
-
kind
:
'
rename'
newName
:
'
rootElement'
# Changes made in https://github.com/flutter/flutter/pull/122555
-
title
:
"
Migrate
to
'decorationClipBehavior'"
date
:
2023-03-13
...
...
packages/flutter/lib/src/widgets/binding.dart
View file @
48bb12df
...
...
@@ -479,8 +479,8 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
}
Future
<
void
>
_forceRebuild
()
{
if
(
r
enderView
Element
!=
null
)
{
buildOwner
!.
reassemble
(
r
enderView
Element
!,
null
);
if
(
r
oot
Element
!=
null
)
{
buildOwner
!.
reassemble
(
r
oot
Element
!,
null
);
return
endOfFrame
;
}
return
Future
<
void
>.
value
();
...
...
@@ -889,8 +889,8 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
}
try
{
if
(
r
enderView
Element
!=
null
)
{
buildOwner
!.
buildScope
(
r
enderView
Element
!);
if
(
r
oot
Element
!=
null
)
{
buildOwner
!.
buildScope
(
r
oot
Element
!);
}
super
.
drawFrame
();
buildOwner
!.
finalizeTree
();
...
...
@@ -914,12 +914,20 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
}
}
/// The [Element] that is at the root of the hierarchy (and which wraps the
/// [RenderView] object at the root of the rendering hierarchy).
/// The [Element] that is at the root of the element tree hierarchy.
///
/// This is initialized the first time [runApp] is called.
Element
?
get
renderViewElement
=>
_renderViewElement
;
Element
?
_renderViewElement
;
Element
?
get
rootElement
=>
_rootElement
;
Element
?
_rootElement
;
/// Deprecated. Will be removed in a future version of Flutter.
///
/// Use [rootElement] instead.
@Deprecated
(
'Use rootElement instead. '
'This feature was deprecated after v3.9.0-16.0.pre.'
)
Element
?
get
renderViewElement
=>
rootElement
;
bool
_readyToProduceFrames
=
false
;
...
...
@@ -951,7 +959,7 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
});
}
/// Takes a widget and attaches it to the [r
enderView
Element], creating it if
/// Takes a widget and attaches it to the [r
oot
Element], creating it if
/// necessary.
///
/// This is called by [runApp] to configure the widget tree.
...
...
@@ -961,23 +969,23 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
/// * [RenderObjectToWidgetAdapter.attachToRenderTree], which inflates a
/// widget and attaches it to the render tree.
void
attachRootWidget
(
Widget
rootWidget
)
{
final
bool
isBootstrapFrame
=
r
enderView
Element
==
null
;
final
bool
isBootstrapFrame
=
r
oot
Element
==
null
;
_readyToProduceFrames
=
true
;
_r
enderView
Element
=
RenderObjectToWidgetAdapter
<
RenderBox
>(
_r
oot
Element
=
RenderObjectToWidgetAdapter
<
RenderBox
>(
container:
renderView
,
debugShortDescription:
'[root]'
,
child:
rootWidget
,
).
attachToRenderTree
(
buildOwner
!,
r
enderView
Element
as
RenderObjectToWidgetElement
<
RenderBox
>?);
).
attachToRenderTree
(
buildOwner
!,
r
oot
Element
as
RenderObjectToWidgetElement
<
RenderBox
>?);
if
(
isBootstrapFrame
)
{
SchedulerBinding
.
instance
.
ensureVisualUpdate
();
}
}
/// Whether the [r
enderView
Element] has been initialized.
/// Whether the [r
oot
Element] has been initialized.
///
/// This will be false until [runApp] is called (or [WidgetTester.pumpWidget]
/// is called in the context of a [TestWidgetsFlutterBinding]).
bool
get
isRootWidgetAttached
=>
_r
enderView
Element
!=
null
;
bool
get
isRootWidgetAttached
=>
_r
oot
Element
!=
null
;
@override
Future
<
void
>
performReassemble
()
{
...
...
@@ -986,8 +994,8 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
return
true
;
}());
if
(
r
enderView
Element
!=
null
)
{
buildOwner
!.
reassemble
(
r
enderView
Element
!,
BindingBase
.
debugReassembleConfig
);
if
(
r
oot
Element
!=
null
)
{
buildOwner
!.
reassemble
(
r
oot
Element
!,
BindingBase
.
debugReassembleConfig
);
}
return
super
.
performReassemble
();
}
...
...
@@ -1069,8 +1077,8 @@ String _debugDumpAppString() {
const
String
mode
=
kDebugMode
?
'DEBUG MODE'
:
kReleaseMode
?
'RELEASE MODE'
:
'PROFILE MODE'
;
final
StringBuffer
buffer
=
StringBuffer
();
buffer
.
writeln
(
'
${WidgetsBinding.instance.runtimeType}
-
$mode
'
);
if
(
WidgetsBinding
.
instance
.
r
enderView
Element
!=
null
)
{
buffer
.
writeln
(
WidgetsBinding
.
instance
.
r
enderView
Element
!.
toStringDeep
());
if
(
WidgetsBinding
.
instance
.
r
oot
Element
!=
null
)
{
buffer
.
writeln
(
WidgetsBinding
.
instance
.
r
oot
Element
!.
toStringDeep
());
}
else
{
buffer
.
writeln
(
'<no tree currently mounted>'
);
}
...
...
@@ -1148,7 +1156,7 @@ class RenderObjectToWidgetAdapter<T extends RenderObject> extends RenderObjectWi
String
toStringShort
()
=>
debugShortDescription
??
super
.
toStringShort
();
}
///
A [RootRenderObjectElement]
that is hosted by a [RenderObject].
///
The root of the element tree
that is hosted by a [RenderObject].
///
/// This element class is the instantiation of a [RenderObjectToWidgetAdapter]
/// widget. It can be used only as the root of an [Element] tree (it cannot be
...
...
@@ -1158,7 +1166,7 @@ class RenderObjectToWidgetAdapter<T extends RenderObject> extends RenderObjectWi
/// whose container is the [RenderView] that connects to the Flutter engine. In
/// this usage, it is normally instantiated by the bootstrapping logic in the
/// [WidgetsFlutterBinding] singleton created by [runApp].
class
RenderObjectToWidgetElement
<
T
extends
RenderObject
>
extends
R
ootRenderObjectElement
{
class
RenderObjectToWidgetElement
<
T
extends
RenderObject
>
extends
R
enderObjectElement
with
RootElementMixin
{
/// Creates an element that is hosted by a [RenderObject].
///
/// The [RenderObject] created by this element is not automatically set as a
...
...
packages/flutter/lib/src/widgets/framework.dart
View file @
48bb12df
...
...
@@ -2499,7 +2499,7 @@ abstract class BuildContext {
/// Additional build owners can be built to manage off-screen widget trees.
///
/// To assign a build owner to a tree, use the
/// [Root
RenderObjectElement
.assignOwner] method on the root element of the
/// [Root
ElementMixin
.assignOwner] method on the root element of the
/// widget tree.
///
/// {@tool dartpad}
...
...
@@ -6323,14 +6323,29 @@ abstract class RenderObjectElement extends Element {
}
}
/// The element at the root of the tree.
/// Deprecated. Unused in the framework and will be removed in a future version
/// of Flutter.
///
/// Only root elements may have their owner set explicitly. All other
/// elements inherit their owner from their parent.
abstract
class
RootRenderObjectElement
extends
RenderObjectElement
{
/// Classes that extend this class can extend [RenderObjectElement] and mixin
/// [RootElementMixin] instead.
@Deprecated
(
'Use RootElementMixin instead. '
'This feature was deprecated after v3.9.0-16.0.pre.'
)
abstract
class
RootRenderObjectElement
extends
RenderObjectElement
with
RootElementMixin
{
/// Initializes fields for subclasses.
@Deprecated
(
'Use RootElementMixin instead. '
'This feature was deprecated after v3.9.0-16.0.pre.'
)
RootRenderObjectElement
(
super
.
widget
);
}
/// Mixin for the element at the root of the tree.
///
/// Only root elements may have their owner set explicitly. All other
/// elements inherit their owner from their parent.
mixin
RootElementMixin
on
Element
{
/// Set the owner of the element. The owner will be propagated to all the
/// descendants of this element.
///
...
...
packages/flutter/lib/src/widgets/widget_inspector.dart
View file @
48bb12df
...
...
@@ -914,8 +914,8 @@ mixin WidgetInspectorService {
@protected
Future
<
void
>
forceRebuild
()
{
final
WidgetsBinding
binding
=
WidgetsBinding
.
instance
;
if
(
binding
.
r
enderView
Element
!=
null
)
{
binding
.
buildOwner
!.
reassemble
(
binding
.
r
enderView
Element
!,
null
);
if
(
binding
.
r
oot
Element
!=
null
)
{
binding
.
buildOwner
!.
reassemble
(
binding
.
r
oot
Element
!,
null
);
return
binding
.
endOfFrame
;
}
return
Future
<
void
>.
value
();
...
...
@@ -1832,7 +1832,7 @@ mixin WidgetInspectorService {
}
Map
<
String
,
Object
?>?
_getRootWidget
(
String
groupName
)
{
return
_nodeToJson
(
WidgetsBinding
.
instance
.
r
enderView
Element
?.
toDiagnosticsNode
(),
InspectorSerializationDelegate
(
groupName:
groupName
,
service:
this
));
return
_nodeToJson
(
WidgetsBinding
.
instance
.
r
oot
Element
?.
toDiagnosticsNode
(),
InspectorSerializationDelegate
(
groupName:
groupName
,
service:
this
));
}
/// Returns a JSON representation of the [DiagnosticsNode] for the root
...
...
@@ -1846,7 +1846,7 @@ mixin WidgetInspectorService {
Map
<
String
,
Object
>?
Function
(
DiagnosticsNode
,
InspectorSerializationDelegate
)?
addAdditionalPropertiesCallback
,
})
{
return
_nodeToJson
(
WidgetsBinding
.
instance
.
r
enderView
Element
?.
toDiagnosticsNode
(),
WidgetsBinding
.
instance
.
r
oot
Element
?.
toDiagnosticsNode
(),
InspectorSerializationDelegate
(
groupName:
groupName
,
subtreeDepth:
1000000
,
...
...
packages/flutter/test/widgets/fast_reassemble_test.dart
View file @
48bb12df
...
...
@@ -17,34 +17,34 @@ void main() {
expect
(
Fizz
.
count
,
0
);
DebugReassembleConfig
config
=
DebugReassembleConfig
(
widgetName:
'Bar'
);
WidgetsBinding
.
instance
.
buildOwner
!.
reassemble
(
WidgetsBinding
.
instance
.
r
enderView
Element
!,
config
);
WidgetsBinding
.
instance
.
buildOwner
!.
reassemble
(
WidgetsBinding
.
instance
.
r
oot
Element
!,
config
);
expect
(
Foo
.
count
,
0
);
expect
(
Bar
.
count
,
1
);
expect
(
Fizz
.
count
,
1
);
config
=
DebugReassembleConfig
(
widgetName:
'Fizz'
);
WidgetsBinding
.
instance
.
buildOwner
!.
reassemble
(
WidgetsBinding
.
instance
.
r
enderView
Element
!,
config
);
WidgetsBinding
.
instance
.
buildOwner
!.
reassemble
(
WidgetsBinding
.
instance
.
r
oot
Element
!,
config
);
expect
(
Foo
.
count
,
0
);
expect
(
Bar
.
count
,
1
);
expect
(
Fizz
.
count
,
2
);
config
=
DebugReassembleConfig
(
widgetName:
'NoMatch'
);
WidgetsBinding
.
instance
.
buildOwner
!.
reassemble
(
WidgetsBinding
.
instance
.
r
enderView
Element
!,
config
);
WidgetsBinding
.
instance
.
buildOwner
!.
reassemble
(
WidgetsBinding
.
instance
.
r
oot
Element
!,
config
);
expect
(
Foo
.
count
,
0
);
expect
(
Bar
.
count
,
1
);
expect
(
Fizz
.
count
,
2
);
config
=
DebugReassembleConfig
();
WidgetsBinding
.
instance
.
buildOwner
!.
reassemble
(
WidgetsBinding
.
instance
.
r
enderView
Element
!,
config
);
WidgetsBinding
.
instance
.
buildOwner
!.
reassemble
(
WidgetsBinding
.
instance
.
r
oot
Element
!,
config
);
expect
(
Foo
.
count
,
1
);
expect
(
Bar
.
count
,
2
);
expect
(
Fizz
.
count
,
3
);
WidgetsBinding
.
instance
.
buildOwner
!.
reassemble
(
WidgetsBinding
.
instance
.
r
enderView
Element
!,
null
);
WidgetsBinding
.
instance
.
buildOwner
!.
reassemble
(
WidgetsBinding
.
instance
.
r
oot
Element
!,
null
);
expect
(
Foo
.
count
,
2
);
expect
(
Bar
.
count
,
3
);
...
...
packages/flutter/test/widgets/memory_allocations_test.dart
View file @
48bb12df
...
...
@@ -58,7 +58,7 @@ class _TestLeafRenderObjectWidget extends LeafRenderObjectWidget {
}
}
class
_TestElement
extends
R
ootRenderObjectElement
{
class
_TestElement
extends
R
enderObjectElement
with
RootElementMixin
{
_TestElement
():
super
(
_TestLeafRenderObjectWidget
());
void
makeInactive
()
{
...
...
packages/flutter/test/widgets/run_app_async_test.dart
View file @
48bb12df
...
...
@@ -50,9 +50,9 @@ void main() {
),
);
// Rendering tree is not built synchronously.
expect
(
WidgetsBinding
.
instance
.
r
enderView
Element
,
isNull
);
expect
(
WidgetsBinding
.
instance
.
r
oot
Element
,
isNull
);
fakeAsync
.
flushTimers
();
expect
(
WidgetsBinding
.
instance
.
r
enderView
Element
,
isNotNull
);
expect
(
WidgetsBinding
.
instance
.
r
oot
Element
,
isNotNull
);
});
});
}
packages/flutter/test/widgets/widget_inspector_test.dart
View file @
48bb12df
...
...
@@ -873,7 +873,7 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
final
List
<
Object
?>
chainElements
=
jsonList
!
as
List
<
Object
?>;
final
List
<
Element
>
expectedChain
=
elementB
.
debugGetDiagnosticChain
().
reversed
.
toList
();
// Sanity check that the chain goes back to the root.
expect
(
expectedChain
.
first
,
tester
.
binding
.
r
enderView
Element
);
expect
(
expectedChain
.
first
,
tester
.
binding
.
r
oot
Element
);
expect
(
chainElements
.
length
,
equals
(
expectedChain
.
length
));
for
(
int
i
=
0
;
i
<
expectedChain
.
length
;
i
+=
1
)
{
...
...
@@ -2081,7 +2081,7 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
final
List
<
Object
?>
chainElements
=
jsonList
!
as
List
<
Object
?>;
final
List
<
Element
>
expectedChain
=
elementB
.
debugGetDiagnosticChain
().
reversed
.
toList
();
// Sanity check that the chain goes back to the root.
expect
(
expectedChain
.
first
,
tester
.
binding
.
r
enderView
Element
);
expect
(
expectedChain
.
first
,
tester
.
binding
.
r
oot
Element
);
expect
(
chainElements
.
length
,
equals
(
expectedChain
.
length
));
for
(
int
i
=
0
;
i
<
expectedChain
.
length
;
i
+=
1
)
{
...
...
@@ -2327,7 +2327,7 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
// directories so we get an empty tree other than the root that is always
// included.
final
Object
?
rootWidget
=
service
.
toObject
(
rootJson
[
'valueId'
]!
as
String
);
expect
(
rootWidget
,
equals
(
WidgetsBinding
.
instance
.
r
enderView
Element
));
expect
(
rootWidget
,
equals
(
WidgetsBinding
.
instance
.
r
oot
Element
));
List
<
Object
?>
childrenJson
=
rootJson
[
'children'
]!
as
List
<
Object
?>;
// There are no summary tree children.
expect
(
childrenJson
.
length
,
equals
(
0
));
...
...
packages/flutter/test/widgets/widget_inspector_test_utils.dart
View file @
48bb12df
...
...
@@ -106,8 +106,8 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService {
rebuildCount
++;
final
WidgetsBinding
binding
=
WidgetsBinding
.
instance
;
if
(
binding
.
r
enderView
Element
!=
null
)
{
binding
.
buildOwner
!.
reassemble
(
binding
.
r
enderView
Element
!,
null
);
if
(
binding
.
r
oot
Element
!=
null
)
{
binding
.
buildOwner
!.
reassemble
(
binding
.
r
oot
Element
!,
null
);
}
}
...
...
packages/flutter/test_fixes/widgets/widgets.dart
View file @
48bb12df
...
...
@@ -12,6 +12,9 @@ void main() {
Object
object
;
TickerProvider
vsync
;
// Changes made in https://github.com/flutter/flutter/pull/123352
WidgetsBinding
.
instance
.
renderViewElement
;
// Changes made in https://github.com/flutter/flutter/pull/119647
MediaQueryData
.
fromWindow
(
View
.
of
(
context
));
...
...
packages/flutter/test_fixes/widgets/widgets.dart.expect
View file @
48bb12df
...
...
@@ -12,6 +12,9 @@ void main() {
Object object;
TickerProvider vsync;
// Changes made in https://github.com/flutter/flutter/pull/123352
WidgetsBinding.instance.rootElement;
// Changes made in https://github.com/flutter/flutter/pull/119647
MediaQueryData.fromView(View.of(context));
...
...
packages/flutter/test_release/widgets/memory_allocations_test.dart
View file @
48bb12df
...
...
@@ -55,7 +55,7 @@ class _TestRenderObject extends RenderObject {
Rect
get
semanticBounds
=>
throw
UnimplementedError
();
}
class
_TestElement
extends
R
ootRenderObjectElement
{
class
_TestElement
extends
R
enderObjectElement
with
RootElementMixin
{
_TestElement
():
super
(
_TestLeafRenderObjectWidget
());
void
makeInactive
()
{
...
...
packages/flutter_test/lib/src/_matchers_web.dart
View file @
48bb12df
...
...
@@ -57,7 +57,7 @@ class MatchesGoldenFile extends AsyncMatcher {
final
RenderObject
renderObject
=
_findRepaintBoundary
(
element
);
final
Size
size
=
renderObject
.
paintBounds
.
size
;
final
TestWidgetsFlutterBinding
binding
=
TestWidgetsFlutterBinding
.
instance
;
final
Element
e
=
binding
.
r
enderView
Element
!;
final
Element
e
=
binding
.
r
oot
Element
!;
final
ui
.
FlutterView
view
=
binding
.
platformDispatcher
.
implicitView
!;
// Unlike `flutter_tester`, we don't have the ability to render an element
...
...
packages/flutter_test/lib/src/binding.dart
View file @
48bb12df
...
...
@@ -908,7 +908,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
// directly called again.
DiagnosticsNode
treeDump
;
try
{
treeDump
=
r
enderView
Element
?.
toDiagnosticsNode
()
??
DiagnosticsNode
.
message
(
'<no tree>'
);
treeDump
=
r
oot
Element
?.
toDiagnosticsNode
()
??
DiagnosticsNode
.
message
(
'<no tree>'
);
// We try to stringify the tree dump here (though we immediately discard the result) because
// we want to make sure that if it can't be serialised, we replace it with a message that
// says the tree could not be serialised. Otherwise, the real exception might get obscured
...
...
@@ -1372,7 +1372,7 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding {
assert
(
inTest
);
try
{
debugBuildingDirtyElements
=
true
;
buildOwner
!.
buildScope
(
r
enderView
Element
!);
buildOwner
!.
buildScope
(
r
oot
Element
!);
if
(
_phase
!=
EnginePhase
.
build
)
{
pipelineOwner
.
flushLayout
();
if
(
_phase
!=
EnginePhase
.
layout
)
{
...
...
packages/flutter_test/lib/src/controller.dart
View file @
48bb12df
...
...
@@ -379,7 +379,7 @@ abstract class WidgetController {
/// using [Iterator.moveNext].
Iterable
<
Element
>
get
allElements
{
TestAsyncUtils
.
guardSync
();
return
collectAllElementsFrom
(
binding
.
r
enderView
Element
!,
skipOffstage:
false
);
return
collectAllElementsFrom
(
binding
.
r
oot
Element
!,
skipOffstage:
false
);
}
/// The matching element in the widget tree.
...
...
packages/flutter_test/lib/src/finders.dart
View file @
48bb12df
...
...
@@ -493,7 +493,7 @@ abstract class Finder {
@protected
Iterable
<
Element
>
get
allCandidates
{
return
collectAllElementsFrom
(
WidgetsBinding
.
instance
.
r
enderView
Element
!,
WidgetsBinding
.
instance
.
r
oot
Element
!,
skipOffstage:
skipOffstage
,
);
}
...
...
packages/flutter_test/lib/src/widget_tester.dart
View file @
48bb12df
...
...
@@ -750,7 +750,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
'your widget tree in a RootRestorationScope?'
,
);
return
TestAsyncUtils
.
guard
<
void
>(()
async
{
final
Widget
widget
=
((
binding
.
r
enderView
Element
!
as
RenderObjectToWidgetElement
<
RenderObject
>).
widget
as
RenderObjectToWidgetAdapter
<
RenderObject
>).
child
!;
final
Widget
widget
=
((
binding
.
r
oot
Element
!
as
RenderObjectToWidgetElement
<
RenderObject
>).
widget
as
RenderObjectToWidgetAdapter
<
RenderObject
>).
child
!;
final
TestRestorationData
restorationData
=
binding
.
restorationManager
.
restorationData
;
runApp
(
Container
(
key:
UniqueKey
()));
await
pump
();
...
...
@@ -863,7 +863,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
.
whereType
<
RenderObject
>()
.
first
;
final
Element
?
innerTargetElement
=
_lastWhereOrNull
(
collectAllElementsFrom
(
binding
.
r
enderView
Element
!,
skipOffstage:
true
),
collectAllElementsFrom
(
binding
.
r
oot
Element
!,
skipOffstage:
true
),
(
Element
element
)
=>
element
.
renderObject
==
innerTarget
,
);
if
(
innerTargetElement
==
null
)
{
...
...
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