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
4f975cbe
Unverified
Commit
4f975cbe
authored
Feb 08, 2022
by
Jonah Williams
Committed by
GitHub
Feb 08, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[framework] inline casts on Element.widget getter to improve web performance (#97822)
parent
d2b5f34b
Changes
21
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
124 additions
and
175 deletions
+124
-175
dialog.dart
packages/flutter/lib/src/cupertino/dialog.dart
+6
-7
text_form_field_row.dart
packages/flutter/lib/src/cupertino/text_form_field_row.dart
+10
-11
text_selection_toolbar.dart
...ges/flutter/lib/src/cupertino/text_selection_toolbar.dart
+11
-12
dropdown.dart
packages/flutter/lib/src/material/dropdown.dart
+3
-4
text_form_field.dart
packages/flutter/lib/src/material/text_form_field.dart
+10
-11
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+1
-4
binding.dart
packages/flutter/lib/src/widgets/binding.dart
+1
-4
framework.dart
packages/flutter/lib/src/widgets/framework.dart
+36
-47
inherited_model.dart
packages/flutter/lib/src/widgets/inherited_model.dart
+1
-4
inherited_notifier.dart
packages/flutter/lib/src/widgets/inherited_notifier.dart
+3
-6
layout_builder.dart
packages/flutter/lib/src/widgets/layout_builder.dart
+1
-4
list_wheel_scroll_view.dart
packages/flutter/lib/src/widgets/list_wheel_scroll_view.dart
+3
-6
notification_listener.dart
packages/flutter/lib/src/widgets/notification_listener.dart
+1
-1
overlay.dart
packages/flutter/lib/src/widgets/overlay.dart
+3
-5
sliver.dart
packages/flutter/lib/src/widgets/sliver.dart
+15
-18
sliver_persistent_header.dart
...ges/flutter/lib/src/widgets/sliver_persistent_header.dart
+6
-8
sliver_prototype_extent_list.dart
...flutter/lib/src/widgets/sliver_prototype_extent_list.dart
+2
-5
slotted_render_object_widget.dart
...flutter/lib/src/widgets/slotted_render_object_widget.dart
+6
-8
table.dart
packages/flutter/lib/src/widgets/table.dart
+1
-4
viewport.dart
packages/flutter/lib/src/widgets/viewport.dart
+3
-5
widget_tester.dart
packages/flutter_test/lib/src/widget_tester.dart
+1
-1
No files found.
packages/flutter/lib/src/cupertino/dialog.dart
View file @
4f975cbe
...
...
@@ -916,9 +916,6 @@ class _CupertinoDialogRenderElement extends RenderObjectElement {
Element
?
_contentElement
;
Element
?
_actionsElement
;
@override
_CupertinoDialogRenderWidget
get
widget
=>
super
.
widget
as
_CupertinoDialogRenderWidget
;
@override
_RenderCupertinoDialog
get
renderObject
=>
super
.
renderObject
as
_RenderCupertinoDialog
;
...
...
@@ -935,8 +932,9 @@ class _CupertinoDialogRenderElement extends RenderObjectElement {
@override
void
mount
(
Element
?
parent
,
Object
?
newSlot
)
{
super
.
mount
(
parent
,
newSlot
);
_contentElement
=
updateChild
(
_contentElement
,
widget
.
contentSection
,
_AlertDialogSections
.
contentSection
);
_actionsElement
=
updateChild
(
_actionsElement
,
widget
.
actionsSection
,
_AlertDialogSections
.
actionsSection
);
final
_CupertinoDialogRenderWidget
dialogRenderWidget
=
widget
as
_CupertinoDialogRenderWidget
;
_contentElement
=
updateChild
(
_contentElement
,
dialogRenderWidget
.
contentSection
,
_AlertDialogSections
.
contentSection
);
_actionsElement
=
updateChild
(
_actionsElement
,
dialogRenderWidget
.
actionsSection
,
_AlertDialogSections
.
actionsSection
);
}
@override
...
...
@@ -957,8 +955,9 @@ class _CupertinoDialogRenderElement extends RenderObjectElement {
@override
void
update
(
RenderObjectWidget
newWidget
)
{
super
.
update
(
newWidget
);
_contentElement
=
updateChild
(
_contentElement
,
widget
.
contentSection
,
_AlertDialogSections
.
contentSection
);
_actionsElement
=
updateChild
(
_actionsElement
,
widget
.
actionsSection
,
_AlertDialogSections
.
actionsSection
);
final
_CupertinoDialogRenderWidget
dialogRenderWidget
=
widget
as
_CupertinoDialogRenderWidget
;
_contentElement
=
updateChild
(
_contentElement
,
dialogRenderWidget
.
contentSection
,
_AlertDialogSections
.
contentSection
);
_actionsElement
=
updateChild
(
_actionsElement
,
dialogRenderWidget
.
actionsSection
,
_AlertDialogSections
.
actionsSection
);
}
@override
...
...
packages/flutter/lib/src/cupertino/text_form_field_row.dart
View file @
4f975cbe
...
...
@@ -274,36 +274,35 @@ class _CupertinoTextFormFieldRowState extends FormFieldState<String> {
TextEditingController
?
_controller
;
TextEditingController
?
get
_effectiveController
=>
widget
.
controller
??
_controller
;
_cupertinoTextFormFieldRow
.
controller
??
_controller
;
@override
CupertinoTextFormFieldRow
get
widget
=>
CupertinoTextFormFieldRow
get
_cupertinoTextFormFieldRow
=>
super
.
widget
as
CupertinoTextFormFieldRow
;
@override
void
initState
()
{
super
.
initState
();
if
(
widget
.
controller
==
null
)
{
if
(
_cupertinoTextFormFieldRow
.
controller
==
null
)
{
_controller
=
TextEditingController
(
text:
widget
.
initialValue
);
}
else
{
widget
.
controller
!.
addListener
(
_handleControllerChanged
);
_cupertinoTextFormFieldRow
.
controller
!.
addListener
(
_handleControllerChanged
);
}
}
@override
void
didUpdateWidget
(
CupertinoTextFormFieldRow
oldWidget
)
{
super
.
didUpdateWidget
(
oldWidget
);
if
(
widget
.
controller
!=
oldWidget
.
controller
)
{
if
(
_cupertinoTextFormFieldRow
.
controller
!=
oldWidget
.
controller
)
{
oldWidget
.
controller
?.
removeListener
(
_handleControllerChanged
);
widget
.
controller
?.
addListener
(
_handleControllerChanged
);
_cupertinoTextFormFieldRow
.
controller
?.
addListener
(
_handleControllerChanged
);
if
(
oldWidget
.
controller
!=
null
&&
widget
.
controller
==
null
)
{
if
(
oldWidget
.
controller
!=
null
&&
_cupertinoTextFormFieldRow
.
controller
==
null
)
{
_controller
=
TextEditingController
.
fromValue
(
oldWidget
.
controller
!.
value
);
}
if
(
widget
.
controller
!=
null
)
{
setValue
(
widget
.
controller
!.
text
);
if
(
_cupertinoTextFormFieldRow
.
controller
!=
null
)
{
setValue
(
_cupertinoTextFormFieldRow
.
controller
!.
text
);
if
(
oldWidget
.
controller
==
null
)
{
_controller
=
null
;
}
...
...
@@ -313,7 +312,7 @@ class _CupertinoTextFormFieldRowState extends FormFieldState<String> {
@override
void
dispose
()
{
widget
.
controller
?.
removeListener
(
_handleControllerChanged
);
_cupertinoTextFormFieldRow
.
controller
?.
removeListener
(
_handleControllerChanged
);
super
.
dispose
();
}
...
...
packages/flutter/lib/src/cupertino/text_selection_toolbar.dart
View file @
4f975cbe
...
...
@@ -522,9 +522,6 @@ class _CupertinoTextSelectionToolbarItemsElement extends RenderObjectElement {
// repeatedly to remove children.
final
Set
<
Element
>
_forgottenChildren
=
HashSet
<
Element
>();
@override
_CupertinoTextSelectionToolbarItems
get
widget
=>
super
.
widget
as
_CupertinoTextSelectionToolbarItems
;
@override
_RenderCupertinoTextSelectionToolbarItems
get
renderObject
=>
super
.
renderObject
as
_RenderCupertinoTextSelectionToolbarItems
;
...
...
@@ -625,15 +622,16 @@ class _CupertinoTextSelectionToolbarItemsElement extends RenderObjectElement {
void
mount
(
Element
?
parent
,
Object
?
newSlot
)
{
super
.
mount
(
parent
,
newSlot
);
// Mount slotted children.
_mountChild
(
widget
.
backButton
,
_CupertinoTextSelectionToolbarItemsSlot
.
backButton
);
_mountChild
(
widget
.
nextButton
,
_CupertinoTextSelectionToolbarItemsSlot
.
nextButton
);
_mountChild
(
widget
.
nextButtonDisabled
,
_CupertinoTextSelectionToolbarItemsSlot
.
nextButtonDisabled
);
final
_CupertinoTextSelectionToolbarItems
toolbarItems
=
widget
as
_CupertinoTextSelectionToolbarItems
;
_mountChild
(
toolbarItems
.
backButton
,
_CupertinoTextSelectionToolbarItemsSlot
.
backButton
);
_mountChild
(
toolbarItems
.
nextButton
,
_CupertinoTextSelectionToolbarItemsSlot
.
nextButton
);
_mountChild
(
toolbarItems
.
nextButtonDisabled
,
_CupertinoTextSelectionToolbarItemsSlot
.
nextButtonDisabled
);
// Mount list children.
_children
=
List
<
Element
>.
filled
(
widget
.
children
.
length
,
_NullElement
.
instance
);
_children
=
List
<
Element
>.
filled
(
toolbarItems
.
children
.
length
,
_NullElement
.
instance
);
Element
?
previousChild
;
for
(
int
i
=
0
;
i
<
_children
.
length
;
i
+=
1
)
{
final
Element
newChild
=
inflateWidget
(
widget
.
children
[
i
],
IndexedSlot
<
Element
?>(
i
,
previousChild
));
final
Element
newChild
=
inflateWidget
(
toolbarItems
.
children
[
i
],
IndexedSlot
<
Element
?>(
i
,
previousChild
));
_children
[
i
]
=
newChild
;
previousChild
=
newChild
;
}
...
...
@@ -659,12 +657,13 @@ class _CupertinoTextSelectionToolbarItemsElement extends RenderObjectElement {
assert
(
widget
==
newWidget
);
// Update slotted children.
_mountChild
(
widget
.
backButton
,
_CupertinoTextSelectionToolbarItemsSlot
.
backButton
);
_mountChild
(
widget
.
nextButton
,
_CupertinoTextSelectionToolbarItemsSlot
.
nextButton
);
_mountChild
(
widget
.
nextButtonDisabled
,
_CupertinoTextSelectionToolbarItemsSlot
.
nextButtonDisabled
);
final
_CupertinoTextSelectionToolbarItems
toolbarItems
=
widget
as
_CupertinoTextSelectionToolbarItems
;
_mountChild
(
toolbarItems
.
backButton
,
_CupertinoTextSelectionToolbarItemsSlot
.
backButton
);
_mountChild
(
toolbarItems
.
nextButton
,
_CupertinoTextSelectionToolbarItemsSlot
.
nextButton
);
_mountChild
(
toolbarItems
.
nextButtonDisabled
,
_CupertinoTextSelectionToolbarItemsSlot
.
nextButtonDisabled
);
// Update list children.
_children
=
updateChildren
(
_children
,
widget
.
children
,
forgottenChildren:
_forgottenChildren
);
_children
=
updateChildren
(
_children
,
toolbarItems
.
children
,
forgottenChildren:
_forgottenChildren
);
_forgottenChildren
.
clear
();
}
}
...
...
packages/flutter/lib/src/material/dropdown.dart
View file @
4f975cbe
...
...
@@ -1665,14 +1665,13 @@ class DropdownButtonFormField<T> extends FormField<T> {
}
class
_DropdownButtonFormFieldState
<
T
>
extends
FormFieldState
<
T
>
{
@override
DropdownButtonFormField
<
T
>
get
widget
=>
super
.
widget
as
DropdownButtonFormField
<
T
>;
@override
void
didChange
(
T
?
value
)
{
super
.
didChange
(
value
);
assert
(
widget
.
onChanged
!=
null
);
widget
.
onChanged
!(
value
);
final
DropdownButtonFormField
<
T
>
dropdownButtonFormField
=
widget
as
DropdownButtonFormField
<
T
>;
assert
(
dropdownButtonFormField
.
onChanged
!=
null
);
dropdownButtonFormField
.
onChanged
!(
value
);
}
@override
...
...
packages/flutter/lib/src/material/text_form_field.dart
View file @
4f975cbe
...
...
@@ -266,10 +266,9 @@ class TextFormField extends FormField<String> {
class
_TextFormFieldState
extends
FormFieldState
<
String
>
{
RestorableTextEditingController
?
_controller
;
TextEditingController
get
_effectiveController
=>
widget
.
controller
??
_controller
!.
value
;
TextEditingController
get
_effectiveController
=>
_textFormField
.
controller
??
_controller
!.
value
;
@override
TextFormField
get
widget
=>
super
.
widget
as
TextFormField
;
TextFormField
get
_textFormField
=>
super
.
widget
as
TextFormField
;
@override
void
restoreState
(
RestorationBucket
?
oldBucket
,
bool
initialRestore
)
{
...
...
@@ -300,26 +299,26 @@ class _TextFormFieldState extends FormFieldState<String> {
@override
void
initState
()
{
super
.
initState
();
if
(
widget
.
controller
==
null
)
{
if
(
_textFormField
.
controller
==
null
)
{
_createLocalController
(
widget
.
initialValue
!=
null
?
TextEditingValue
(
text:
widget
.
initialValue
!)
:
null
);
}
else
{
widget
.
controller
!.
addListener
(
_handleControllerChanged
);
_textFormField
.
controller
!.
addListener
(
_handleControllerChanged
);
}
}
@override
void
didUpdateWidget
(
TextFormField
oldWidget
)
{
super
.
didUpdateWidget
(
oldWidget
);
if
(
widget
.
controller
!=
oldWidget
.
controller
)
{
if
(
_textFormField
.
controller
!=
oldWidget
.
controller
)
{
oldWidget
.
controller
?.
removeListener
(
_handleControllerChanged
);
widget
.
controller
?.
addListener
(
_handleControllerChanged
);
_textFormField
.
controller
?.
addListener
(
_handleControllerChanged
);
if
(
oldWidget
.
controller
!=
null
&&
widget
.
controller
==
null
)
{
if
(
oldWidget
.
controller
!=
null
&&
_textFormField
.
controller
==
null
)
{
_createLocalController
(
oldWidget
.
controller
!.
value
);
}
if
(
widget
.
controller
!=
null
)
{
setValue
(
widget
.
controller
!.
text
);
if
(
_textFormField
.
controller
!=
null
)
{
setValue
(
_textFormField
.
controller
!.
text
);
if
(
oldWidget
.
controller
==
null
)
{
unregisterFromRestoration
(
_controller
!);
_controller
!.
dispose
();
...
...
@@ -331,7 +330,7 @@ class _TextFormFieldState extends FormFieldState<String> {
@override
void
dispose
()
{
widget
.
controller
?.
removeListener
(
_handleControllerChanged
);
_textFormField
.
controller
?.
removeListener
(
_handleControllerChanged
);
_controller
?.
dispose
();
super
.
dispose
();
}
...
...
packages/flutter/lib/src/widgets/basic.dart
View file @
4f975cbe
...
...
@@ -3131,12 +3131,9 @@ class Offstage extends SingleChildRenderObjectWidget {
class
_OffstageElement
extends
SingleChildRenderObjectElement
{
_OffstageElement
(
Offstage
widget
)
:
super
(
widget
);
@override
Offstage
get
widget
=>
super
.
widget
as
Offstage
;
@override
void
debugVisitOnstageChildren
(
ElementVisitor
visitor
)
{
if
(!
widget
.
offstage
)
if
(!
(
widget
as
Offstage
)
.
offstage
)
super
.
debugVisitOnstageChildren
(
visitor
);
}
}
...
...
packages/flutter/lib/src/widgets/binding.dart
View file @
4f975cbe
...
...
@@ -1138,9 +1138,6 @@ class RenderObjectToWidgetElement<T extends RenderObject> extends RootRenderObje
/// the render tree, call [RenderObjectToWidgetAdapter.attachToRenderTree].
RenderObjectToWidgetElement
(
RenderObjectToWidgetAdapter
<
T
>
widget
)
:
super
(
widget
);
@override
RenderObjectToWidgetAdapter
<
T
>
get
widget
=>
super
.
widget
as
RenderObjectToWidgetAdapter
<
T
>;
Element
?
_child
;
static
const
Object
_rootChildSlot
=
Object
();
...
...
@@ -1193,7 +1190,7 @@ class RenderObjectToWidgetElement<T extends RenderObject> extends RootRenderObje
@pragma
(
'vm:notify-debugger-on-exception'
)
void
_rebuild
()
{
try
{
_child
=
updateChild
(
_child
,
widget
.
child
,
_rootChildSlot
);
_child
=
updateChild
(
_child
,
(
widget
as
RenderObjectToWidgetAdapter
<
T
>)
.
child
,
_rootChildSlot
);
}
catch
(
exception
,
stack
)
{
final
FlutterErrorDetails
details
=
FlutterErrorDetails
(
exception:
exception
,
...
...
packages/flutter/lib/src/widgets/framework.dart
View file @
4f975cbe
This diff is collapsed.
Click to expand it.
packages/flutter/lib/src/widgets/inherited_model.dart
View file @
4f975cbe
...
...
@@ -184,9 +184,6 @@ class InheritedModelElement<T> extends InheritedElement {
/// Creates an element that uses the given widget as its configuration.
InheritedModelElement
(
InheritedModel
<
T
>
widget
)
:
super
(
widget
);
@override
InheritedModel
<
T
>
get
widget
=>
super
.
widget
as
InheritedModel
<
T
>;
@override
void
updateDependencies
(
Element
dependent
,
Object
?
aspect
)
{
final
Set
<
T
>?
dependencies
=
getDependencies
(
dependent
)
as
Set
<
T
>?;
...
...
@@ -206,7 +203,7 @@ class InheritedModelElement<T> extends InheritedElement {
final
Set
<
T
>?
dependencies
=
getDependencies
(
dependent
)
as
Set
<
T
>?;
if
(
dependencies
==
null
)
return
;
if
(
dependencies
.
isEmpty
||
widget
.
updateShouldNotifyDependent
(
oldWidget
,
dependencies
))
if
(
dependencies
.
isEmpty
||
(
widget
as
InheritedModel
<
T
>)
.
updateShouldNotifyDependent
(
oldWidget
,
dependencies
))
dependent
.
didChangeDependencies
();
}
}
packages/flutter/lib/src/widgets/inherited_notifier.dart
View file @
4f975cbe
...
...
@@ -95,14 +95,11 @@ class _InheritedNotifierElement<T extends Listenable> extends InheritedElement {
widget
.
notifier
?.
addListener
(
_handleUpdate
);
}
@override
InheritedNotifier
<
T
>
get
widget
=>
super
.
widget
as
InheritedNotifier
<
T
>;
bool
_dirty
=
false
;
@override
void
update
(
InheritedNotifier
<
T
>
newWidget
)
{
final
T
?
oldNotifier
=
widget
.
notifier
;
final
T
?
oldNotifier
=
(
widget
as
InheritedNotifier
<
T
>)
.
notifier
;
final
T
?
newNotifier
=
newWidget
.
notifier
;
if
(
oldNotifier
!=
newNotifier
)
{
oldNotifier
?.
removeListener
(
_handleUpdate
);
...
...
@@ -114,7 +111,7 @@ class _InheritedNotifierElement<T extends Listenable> extends InheritedElement {
@override
Widget
build
()
{
if
(
_dirty
)
notifyClients
(
widget
);
notifyClients
(
widget
as
InheritedNotifier
<
T
>
);
return
super
.
build
();
}
...
...
@@ -131,7 +128,7 @@ class _InheritedNotifierElement<T extends Listenable> extends InheritedElement {
@override
void
unmount
()
{
widget
.
notifier
?.
removeListener
(
_handleUpdate
);
(
widget
as
InheritedNotifier
<
T
>)
.
notifier
?.
removeListener
(
_handleUpdate
);
super
.
unmount
();
}
}
packages/flutter/lib/src/widgets/layout_builder.dart
View file @
4f975cbe
...
...
@@ -57,9 +57,6 @@ abstract class ConstrainedLayoutBuilder<ConstraintType extends Constraints> exte
class
_LayoutBuilderElement
<
ConstraintType
extends
Constraints
>
extends
RenderObjectElement
{
_LayoutBuilderElement
(
ConstrainedLayoutBuilder
<
ConstraintType
>
widget
)
:
super
(
widget
);
@override
ConstrainedLayoutBuilder
<
ConstraintType
>
get
widget
=>
super
.
widget
as
ConstrainedLayoutBuilder
<
ConstraintType
>;
@override
RenderConstrainedLayoutBuilder
<
ConstraintType
,
RenderObject
>
get
renderObject
=>
super
.
renderObject
as
RenderConstrainedLayoutBuilder
<
ConstraintType
,
RenderObject
>;
...
...
@@ -119,7 +116,7 @@ class _LayoutBuilderElement<ConstraintType extends Constraints> extends RenderOb
void
layoutCallback
()
{
Widget
built
;
try
{
built
=
widget
.
builder
(
this
,
constraints
);
built
=
(
widget
as
ConstrainedLayoutBuilder
<
ConstraintType
>)
.
builder
(
this
,
constraints
);
debugWidgetBuilderValue
(
widget
,
built
);
}
catch
(
e
,
stack
)
{
built
=
ErrorWidget
.
builder
(
...
...
packages/flutter/lib/src/widgets/list_wheel_scroll_view.dart
View file @
4f975cbe
...
...
@@ -818,9 +818,6 @@ class ListWheelElement extends RenderObjectElement implements ListWheelChildMana
/// Creates an element that lazily builds children for the given widget.
ListWheelElement
(
ListWheelViewport
widget
)
:
super
(
widget
);
@override
ListWheelViewport
get
widget
=>
super
.
widget
as
ListWheelViewport
;
@override
RenderListWheelViewport
get
renderObject
=>
super
.
renderObject
as
RenderListWheelViewport
;
...
...
@@ -840,7 +837,7 @@ class ListWheelElement extends RenderObjectElement implements ListWheelChildMana
@override
void
update
(
ListWheelViewport
newWidget
)
{
final
ListWheelViewport
oldWidget
=
widget
;
final
ListWheelViewport
oldWidget
=
widget
as
ListWheelViewport
;
super
.
update
(
newWidget
);
final
ListWheelChildDelegate
newDelegate
=
newWidget
.
childDelegate
;
final
ListWheelChildDelegate
oldDelegate
=
oldWidget
.
childDelegate
;
...
...
@@ -852,7 +849,7 @@ class ListWheelElement extends RenderObjectElement implements ListWheelChildMana
}
@override
int
?
get
childCount
=>
widget
.
childDelegate
.
estimatedChildCount
;
int
?
get
childCount
=>
(
widget
as
ListWheelViewport
)
.
childDelegate
.
estimatedChildCount
;
@override
void
performRebuild
()
{
...
...
@@ -880,7 +877,7 @@ class ListWheelElement extends RenderObjectElement implements ListWheelChildMana
/// will be cached. However when the element is rebuilt, the cache will be
/// cleared.
Widget
?
retrieveWidget
(
int
index
)
{
return
_childWidgets
.
putIfAbsent
(
index
,
()
=>
widget
.
childDelegate
.
build
(
this
,
index
));
return
_childWidgets
.
putIfAbsent
(
index
,
()
=>
(
widget
as
ListWheelViewport
)
.
childDelegate
.
build
(
this
,
index
));
}
@override
...
...
packages/flutter/lib/src/widgets/notification_listener.dart
View file @
4f975cbe
...
...
@@ -62,7 +62,7 @@ abstract class Notification {
@mustCallSuper
bool
visitAncestor
(
Element
element
)
{
if
(
element
is
StatelessElement
)
{
final
Stateless
Widget
widget
=
element
.
widget
;
final
Widget
widget
=
element
.
widget
;
if
(
widget
is
NotificationListener
<
Notification
>)
{
if
(
widget
.
_dispatch
(
this
,
element
))
// that function checks the type dynamically
return
false
;
...
...
packages/flutter/lib/src/widgets/overlay.dart
View file @
4f975cbe
...
...
@@ -578,16 +578,14 @@ class _Theatre extends MultiChildRenderObjectWidget {
class
_TheatreElement
extends
MultiChildRenderObjectElement
{
_TheatreElement
(
_Theatre
widget
)
:
super
(
widget
);
@override
_Theatre
get
widget
=>
super
.
widget
as
_Theatre
;
@override
_RenderTheatre
get
renderObject
=>
super
.
renderObject
as
_RenderTheatre
;
@override
void
debugVisitOnstageChildren
(
ElementVisitor
visitor
)
{
assert
(
children
.
length
>=
widget
.
skipCount
);
children
.
skip
(
widget
.
skipCount
).
forEach
(
visitor
);
final
_Theatre
theatre
=
widget
as
_Theatre
;
assert
(
children
.
length
>=
theatre
.
skipCount
);
children
.
skip
(
theatre
.
skipCount
).
forEach
(
visitor
);
}
}
...
...
packages/flutter/lib/src/widgets/sliver.dart
View file @
4f975cbe
...
...
@@ -1126,15 +1126,12 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render
final
bool
_replaceMovedChildren
;
@override
SliverMultiBoxAdaptorWidget
get
widget
=>
super
.
widget
as
SliverMultiBoxAdaptorWidget
;
@override
RenderSliverMultiBoxAdaptor
get
renderObject
=>
super
.
renderObject
as
RenderSliverMultiBoxAdaptor
;
@override
void
update
(
covariant
SliverMultiBoxAdaptorWidget
newWidget
)
{
final
SliverMultiBoxAdaptorWidget
oldWidget
=
widget
;
final
SliverMultiBoxAdaptorWidget
oldWidget
=
widget
as
SliverMultiBoxAdaptorWidget
;
super
.
update
(
newWidget
);
final
SliverChildDelegate
newDelegate
=
newWidget
.
delegate
;
final
SliverChildDelegate
oldDelegate
=
oldWidget
.
delegate
;
...
...
@@ -1155,6 +1152,7 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render
try
{
final
SplayTreeMap
<
int
,
Element
?>
newChildren
=
SplayTreeMap
<
int
,
Element
?>();
final
Map
<
int
,
double
>
indexToLayoutOffset
=
HashMap
<
int
,
double
>();
final
SliverMultiBoxAdaptorWidget
adaptorWidget
=
widget
as
SliverMultiBoxAdaptorWidget
;
void
processElement
(
int
index
)
{
_currentlyUpdatingChildIndex
=
index
;
if
(
_childElements
[
index
]
!=
null
&&
_childElements
[
index
]
!=
newChildren
[
index
])
{
...
...
@@ -1162,7 +1160,7 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render
_childElements
[
index
]
=
updateChild
(
_childElements
[
index
],
null
,
index
);
childrenUpdated
=
true
;
}
final
Element
?
newChild
=
updateChild
(
newChildren
[
index
],
_build
(
index
),
index
);
final
Element
?
newChild
=
updateChild
(
newChildren
[
index
],
_build
(
index
,
adaptorWidget
),
index
);
if
(
newChild
!=
null
)
{
childrenUpdated
=
childrenUpdated
||
_childElements
[
index
]
!=
newChild
;
_childElements
[
index
]
=
newChild
;
...
...
@@ -1181,7 +1179,7 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render
}
for
(
final
int
index
in
_childElements
.
keys
.
toList
())
{
final
Key
?
key
=
_childElements
[
index
]!.
widget
.
key
;
final
int
?
newIndex
=
key
==
null
?
null
:
w
idget
.
delegate
.
findIndexByKey
(
key
);
final
int
?
newIndex
=
key
==
null
?
null
:
adaptorW
idget
.
delegate
.
findIndexByKey
(
key
);
final
SliverMultiBoxAdaptorParentData
?
childParentData
=
_childElements
[
index
]!.
renderObject
?.
parentData
as
SliverMultiBoxAdaptorParentData
?;
...
...
@@ -1228,7 +1226,7 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render
}
}
Widget
?
_build
(
int
index
)
{
Widget
?
_build
(
int
index
,
SliverMultiBoxAdaptorWidget
widget
)
{
return
widget
.
delegate
.
build
(
this
,
index
);
}
...
...
@@ -1241,8 +1239,9 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render
_currentBeforeChild
=
insertFirst
?
null
:
(
_childElements
[
index
-
1
]!.
renderObject
as
RenderBox
?);
Element
?
newChild
;
try
{
final
SliverMultiBoxAdaptorWidget
adaptorWidget
=
widget
as
SliverMultiBoxAdaptorWidget
;
_currentlyUpdatingChildIndex
=
index
;
newChild
=
updateChild
(
_childElements
[
index
],
_build
(
index
),
index
);
newChild
=
updateChild
(
_childElements
[
index
],
_build
(
index
,
adaptorWidget
),
index
);
}
finally
{
_currentlyUpdatingChildIndex
=
null
;
}
...
...
@@ -1321,7 +1320,7 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render
final
int
?
childCount
=
estimatedChildCount
;
if
(
childCount
==
null
)
return
double
.
infinity
;
return
widget
.
estimateMaxScrollOffset
(
return
(
widget
as
SliverMultiBoxAdaptorWidget
)
.
estimateMaxScrollOffset
(
constraints
,
firstIndex
!,
lastIndex
!,
...
...
@@ -1345,7 +1344,7 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render
/// See also:
///
/// * [SliverChildDelegate.estimatedChildCount], to which this getter defers.
int
?
get
estimatedChildCount
=>
widget
.
delegate
.
estimatedChildCount
;
int
?
get
estimatedChildCount
=>
(
widget
as
SliverMultiBoxAdaptorWidget
)
.
delegate
.
estimatedChildCount
;
@override
int
get
childCount
{
...
...
@@ -1358,10 +1357,11 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render
// manually.
int
lo
=
0
;
int
hi
=
1
;
final
SliverMultiBoxAdaptorWidget
adaptorWidget
=
widget
as
SliverMultiBoxAdaptorWidget
;
const
int
max
=
kIsWeb
?
9007199254740992
// max safe integer on JS (from 0 to this number x != x+1)
:
((
1
<<
63
)
-
1
);
while
(
_build
(
hi
-
1
)
!=
null
)
{
while
(
_build
(
hi
-
1
,
adaptorWidget
)
!=
null
)
{
lo
=
hi
-
1
;
if
(
hi
<
max
~/
2
)
{
hi
*=
2
;
...
...
@@ -1369,7 +1369,7 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render
hi
=
max
;
}
else
{
throw
FlutterError
(
'Could not find the number of children in
${
w
idget.delegate}
.
\n
'
'Could not find the number of children in
${
adaptorW
idget.delegate}
.
\n
'
"The childCount getter was called (implying that the delegate's builder returned null "
'for a positive index), but even building the child with index
$hi
(the maximum '
'possible integer) did not return null. Consider implementing childCount to avoid '
...
...
@@ -1379,7 +1379,7 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render
}
while
(
hi
-
lo
>
1
)
{
final
int
mid
=
(
hi
-
lo
)
~/
2
+
lo
;
if
(
_build
(
mid
-
1
)
==
null
)
{
if
(
_build
(
mid
-
1
,
adaptorWidget
)
==
null
)
{
hi
=
mid
;
}
else
{
lo
=
mid
;
...
...
@@ -1400,7 +1400,7 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render
assert
(
debugAssertChildListLocked
());
final
int
firstIndex
=
_childElements
.
firstKey
()
??
0
;
final
int
lastIndex
=
_childElements
.
lastKey
()
??
0
;
widget
.
delegate
.
didFinishLayout
(
firstIndex
,
lastIndex
);
(
widget
as
SliverMultiBoxAdaptorWidget
)
.
delegate
.
didFinishLayout
(
firstIndex
,
lastIndex
);
}
int
?
_currentlyUpdatingChildIndex
;
...
...
@@ -1694,12 +1694,9 @@ class SliverOffstage extends SingleChildRenderObjectWidget {
class
_SliverOffstageElement
extends
SingleChildRenderObjectElement
{
_SliverOffstageElement
(
SliverOffstage
widget
)
:
super
(
widget
);
@override
SliverOffstage
get
widget
=>
super
.
widget
as
SliverOffstage
;
@override
void
debugVisitOnstageChildren
(
ElementVisitor
visitor
)
{
if
(!
widget
.
offstage
)
if
(!
(
widget
as
SliverOffstage
)
.
offstage
)
super
.
debugVisitOnstageChildren
(
visitor
);
}
}
...
...
packages/flutter/lib/src/widgets/sliver_persistent_header.dart
View file @
4f975cbe
...
...
@@ -254,9 +254,6 @@ class _SliverPersistentHeaderElement extends RenderObjectElement {
final
bool
floating
;
@override
_SliverPersistentHeaderRenderObjectWidget
get
widget
=>
super
.
widget
as
_SliverPersistentHeaderRenderObjectWidget
;
@override
_RenderSliverPersistentHeaderForWidgetsMixin
get
renderObject
=>
super
.
renderObject
as
_RenderSliverPersistentHeaderForWidgetsMixin
;
...
...
@@ -274,7 +271,7 @@ class _SliverPersistentHeaderElement extends RenderObjectElement {
@override
void
update
(
_SliverPersistentHeaderRenderObjectWidget
newWidget
)
{
final
_SliverPersistentHeaderRenderObjectWidget
oldWidget
=
widget
;
final
_SliverPersistentHeaderRenderObjectWidget
oldWidget
=
widget
as
_SliverPersistentHeaderRenderObjectWidget
;
super
.
update
(
newWidget
);
final
SliverPersistentHeaderDelegate
newDelegate
=
newWidget
.
delegate
;
final
SliverPersistentHeaderDelegate
oldDelegate
=
oldWidget
.
delegate
;
...
...
@@ -293,15 +290,16 @@ class _SliverPersistentHeaderElement extends RenderObjectElement {
void
_build
(
double
shrinkOffset
,
bool
overlapsContent
)
{
owner
!.
buildScope
(
this
,
()
{
final
_SliverPersistentHeaderRenderObjectWidget
sliverPersistentHeaderRenderObjectWidget
=
widget
as
_SliverPersistentHeaderRenderObjectWidget
;
child
=
updateChild
(
child
,
floating
?
_FloatingHeader
(
child:
w
idget
.
delegate
.
build
(
?
_FloatingHeader
(
child:
sliverPersistentHeaderRenderObjectW
idget
.
delegate
.
build
(
this
,
shrinkOffset
,
overlapsContent
))
:
w
idget
.
delegate
.
build
(
this
,
shrinkOffset
,
overlapsContent
),
:
sliverPersistentHeaderRenderObjectW
idget
.
delegate
.
build
(
this
,
shrinkOffset
,
overlapsContent
),
null
,
);
});
...
...
@@ -371,10 +369,10 @@ mixin _RenderSliverPersistentHeaderForWidgetsMixin on RenderSliverPersistentHead
_SliverPersistentHeaderElement
?
_element
;
@override
double
get
minExtent
=>
_element
!.
widget
.
delegate
.
minExtent
;
double
get
minExtent
=>
(
_element
!.
widget
as
_SliverPersistentHeaderRenderObjectWidget
)
.
delegate
.
minExtent
;
@override
double
get
maxExtent
=>
_element
!.
widget
.
delegate
.
maxExtent
;
double
get
maxExtent
=>
(
_element
!.
widget
as
_SliverPersistentHeaderRenderObjectWidget
)
.
delegate
.
maxExtent
;
@override
void
updateChild
(
double
shrinkOffset
,
bool
overlapsContent
)
{
...
...
packages/flutter/lib/src/widgets/sliver_prototype_extent_list.dart
View file @
4f975cbe
...
...
@@ -62,9 +62,6 @@ class SliverPrototypeExtentList extends SliverMultiBoxAdaptorWidget {
class
_SliverPrototypeExtentListElement
extends
SliverMultiBoxAdaptorElement
{
_SliverPrototypeExtentListElement
(
SliverPrototypeExtentList
widget
)
:
super
(
widget
);
@override
SliverPrototypeExtentList
get
widget
=>
super
.
widget
as
SliverPrototypeExtentList
;
@override
_RenderSliverPrototypeExtentList
get
renderObject
=>
super
.
renderObject
as
_RenderSliverPrototypeExtentList
;
...
...
@@ -113,14 +110,14 @@ class _SliverPrototypeExtentListElement extends SliverMultiBoxAdaptorElement {
@override
void
mount
(
Element
?
parent
,
Object
?
newSlot
)
{
super
.
mount
(
parent
,
newSlot
);
_prototype
=
updateChild
(
_prototype
,
widget
.
prototypeItem
,
_prototypeSlot
);
_prototype
=
updateChild
(
_prototype
,
(
widget
as
SliverPrototypeExtentList
)
.
prototypeItem
,
_prototypeSlot
);
}
@override
void
update
(
SliverPrototypeExtentList
newWidget
)
{
super
.
update
(
newWidget
);
assert
(
widget
==
newWidget
);
_prototype
=
updateChild
(
_prototype
,
widget
.
prototypeItem
,
_prototypeSlot
);
_prototype
=
updateChild
(
_prototype
,
(
widget
as
SliverPrototypeExtentList
)
.
prototypeItem
,
_prototypeSlot
);
}
}
...
...
packages/flutter/lib/src/widgets/slotted_render_object_widget.dart
View file @
4f975cbe
...
...
@@ -191,9 +191,6 @@ class SlottedRenderObjectElement<S> extends RenderObjectElement {
final
Map
<
S
,
Element
>
_slotToChild
=
<
S
,
Element
>{};
@override
SlottedMultiChildRenderObjectWidgetMixin
<
S
>
get
widget
=>
super
.
widget
as
SlottedMultiChildRenderObjectWidgetMixin
<
S
>;
@override
SlottedContainerRenderObjectMixin
<
S
>
get
renderObject
=>
super
.
renderObject
as
SlottedContainerRenderObjectMixin
<
S
>;
...
...
@@ -227,14 +224,15 @@ class SlottedRenderObjectElement<S> extends RenderObjectElement {
List
<
S
>?
_debugPreviousSlots
;
void
_updateChildren
()
{
final
SlottedMultiChildRenderObjectWidgetMixin
<
S
>
slottedMultiChildRenderObjectWidgetMixin
=
widget
as
SlottedMultiChildRenderObjectWidgetMixin
<
S
>;
assert
(()
{
_debugPreviousSlots
??=
widget
.
slots
.
toList
();
return
listEquals
(
_debugPreviousSlots
,
widget
.
slots
.
toList
());
_debugPreviousSlots
??=
slottedMultiChildRenderObjectWidgetMixin
.
slots
.
toList
();
return
listEquals
(
_debugPreviousSlots
,
slottedMultiChildRenderObjectWidgetMixin
.
slots
.
toList
());
}(),
'
${widget.runtimeType}
.slots must not change.'
);
assert
(
widget
.
slots
.
toSet
().
length
==
widget
.
slots
.
length
,
'slots must be unique'
);
assert
(
slottedMultiChildRenderObjectWidgetMixin
.
slots
.
toSet
().
length
==
slottedMultiChildRenderObjectWidgetMixin
.
slots
.
length
,
'slots must be unique'
);
for
(
final
S
slot
in
widget
.
slots
)
{
_updateChild
(
widget
.
childForSlot
(
slot
),
slot
);
for
(
final
S
slot
in
slottedMultiChildRenderObjectWidgetMixin
.
slots
)
{
_updateChild
(
slottedMultiChildRenderObjectWidgetMixin
.
childForSlot
(
slot
),
slot
);
}
}
...
...
packages/flutter/lib/src/widgets/table.dart
View file @
4f975cbe
...
...
@@ -284,9 +284,6 @@ class Table extends RenderObjectWidget {
class
_TableElement
extends
RenderObjectElement
{
_TableElement
(
Table
widget
)
:
super
(
widget
);
@override
Table
get
widget
=>
super
.
widget
as
Table
;
@override
RenderTable
get
renderObject
=>
super
.
renderObject
as
RenderTable
;
...
...
@@ -300,7 +297,7 @@ class _TableElement extends RenderObjectElement {
_doingMountOrUpdate
=
true
;
super
.
mount
(
parent
,
newSlot
);
int
rowIndex
=
-
1
;
_children
=
widget
.
children
.
map
<
_TableElementRow
>((
TableRow
row
)
{
_children
=
(
widget
as
Table
)
.
children
.
map
<
_TableElementRow
>((
TableRow
row
)
{
int
columnIndex
=
0
;
rowIndex
+=
1
;
return
_TableElementRow
(
...
...
packages/flutter/lib/src/widgets/viewport.dart
View file @
4f975cbe
...
...
@@ -214,9 +214,6 @@ class _ViewportElement extends MultiChildRenderObjectElement {
bool
_doingMountOrUpdate
=
false
;
int
?
_centerSlotIndex
;
@override
Viewport
get
widget
=>
super
.
widget
as
Viewport
;
@override
RenderViewport
get
renderObject
=>
super
.
renderObject
as
RenderViewport
;
...
...
@@ -242,10 +239,11 @@ class _ViewportElement extends MultiChildRenderObjectElement {
void
_updateCenter
()
{
// TODO(ianh): cache the keys to make this faster
if
(
widget
.
center
!=
null
)
{
final
Viewport
viewport
=
widget
as
Viewport
;
if
(
viewport
.
center
!=
null
)
{
int
elementIndex
=
0
;
for
(
final
Element
e
in
children
)
{
if
(
e
.
widget
.
key
==
widge
t
.
center
)
{
if
(
e
.
widget
.
key
==
viewpor
t
.
center
)
{
renderObject
.
center
=
e
.
renderObject
as
RenderSliver
?;
break
;
}
...
...
packages/flutter_test/lib/src/widget_tester.dart
View file @
4f975cbe
...
...
@@ -709,7 +709,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker
'therefore no restoration data has been collected to restore from. Did you forget to wrap '
'your widget tree in a RootRestorationScope?'
,
);
final
Widget
widget
=
(
binding
.
renderViewElement
!
as
RenderObjectToWidgetElement
<
RenderObject
>).
widget
.
child
!;
final
Widget
widget
=
(
(
binding
.
renderViewElement
!
as
RenderObjectToWidgetElement
<
RenderObject
>).
widget
as
RenderObjectToWidgetAdapter
<
RenderObject
>)
.
child
!;
final
TestRestorationData
restorationData
=
binding
.
restorationManager
.
restorationData
;
runApp
(
Container
(
key:
UniqueKey
()));
await
pump
();
...
...
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