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
7f41ab25
Unverified
Commit
7f41ab25
authored
Mar 23, 2023
by
Michael Goderbauer
Committed by
GitHub
Mar 23, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix (insert|move|remove)RenderObjectChild methods in base class (#123276)
parent
31798757
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
95 deletions
+40
-95
dialog.dart
packages/flutter/lib/src/cupertino/dialog.dart
+1
-1
framework.dart
packages/flutter/lib/src/widgets/framework.dart
+3
-72
framework_test.dart
packages/flutter/test/widgets/framework_test.dart
+9
-0
memory_allocations_test.dart
packages/flutter/test/widgets/memory_allocations_test.dart
+9
-0
render_object_element_test.dart
...ages/flutter/test/widgets/render_object_element_test.dart
+9
-22
memory_allocations_test.dart
...flutter/test_release/widgets/memory_allocations_test.dart
+9
-0
No files found.
packages/flutter/lib/src/cupertino/dialog.dart
View file @
7f41ab25
...
...
@@ -856,7 +856,7 @@ class _CupertinoDialogRenderElement extends RenderObjectElement {
@override
void
moveRenderObjectChild
(
RenderObject
child
,
_AlertDialogSections
oldSlot
,
_AlertDialogSections
newSlot
)
{
if
(!
allowMoveRenderObjectChild
)
{
super
.
moveRenderObjectChild
(
child
,
oldSlot
,
newSlot
);
assert
(
false
);
return
;
}
...
...
packages/flutter/lib/src/widgets/framework.dart
View file @
7f41ab25
...
...
@@ -6290,30 +6290,7 @@ abstract class RenderObjectElement extends Element {
/// [IndexedSlot] is a convenient value for the slot.
/// {@endtemplate}
@protected
void
insertRenderObjectChild
(
covariant
RenderObject
child
,
covariant
Object
?
slot
)
{
assert
(()
{
throw
FlutterError
.
fromParts
(<
DiagnosticsNode
>[
ErrorSummary
(
'RenderObjectElement.insertChildRenderObject() is deprecated.'
),
toDiagnosticsNode
(
name:
'insertChildRenderObject() was called on this Element'
,
style:
DiagnosticsTreeStyle
.
shallow
,
),
ErrorDescription
(
'insertChildRenderObject() has been deprecated in favor of '
'insertRenderObjectChild(). See https://github.com/flutter/flutter/issues/63269 '
'for details.'
,
),
ErrorHint
(
'Rather than overriding insertChildRenderObject() in your '
'RenderObjectElement subclass, override insertRenderObjectChild() instead, '
"and DON'T call super.insertRenderObjectChild(). If you're implementing a "
'new RenderObjectElement, you should override/implement '
'insertRenderObjectChild(), moveRenderObjectChild(), and '
'removeRenderObjectChild().'
,
),
]);
}());
}
void
insertRenderObjectChild
(
covariant
RenderObject
child
,
covariant
Object
?
slot
);
/// Move the given child from the given old slot to the given new slot.
///
...
...
@@ -6330,60 +6307,14 @@ abstract class RenderObjectElement extends Element {
/// compared against each other for the purposes of updating one slot with the
/// element from another slot) would never call this.
@protected
void
moveRenderObjectChild
(
covariant
RenderObject
child
,
covariant
Object
?
oldSlot
,
covariant
Object
?
newSlot
)
{
assert
(()
{
throw
FlutterError
.
fromParts
(<
DiagnosticsNode
>[
ErrorSummary
(
'RenderObjectElement.moveChildRenderObject() is deprecated.'
),
toDiagnosticsNode
(
name:
'super.moveChildRenderObject() was called on this Element'
,
style:
DiagnosticsTreeStyle
.
shallow
,
),
ErrorDescription
(
'moveChildRenderObject() has been deprecated in favor of '
'moveRenderObjectChild(). See https://github.com/flutter/flutter/issues/63269 '
'for details.'
,
),
ErrorHint
(
'Rather than overriding moveChildRenderObject() in your '
'RenderObjectElement subclass, override moveRenderObjectChild() instead, '
"and DON'T call super.moveRenderObjectChild(). If you're implementing a "
'new RenderObjectElement, you should override/implement '
'insertRenderObjectChild(), moveRenderObjectChild(), and '
'removeRenderObjectChild().'
,
),
]);
}());
}
void
moveRenderObjectChild
(
covariant
RenderObject
child
,
covariant
Object
?
oldSlot
,
covariant
Object
?
newSlot
);
/// Remove the given child from [renderObject].
///
/// The given child is guaranteed to have been inserted at the given `slot`
/// and have [renderObject] as its parent.
@protected
void
removeRenderObjectChild
(
covariant
RenderObject
child
,
covariant
Object
?
slot
)
{
assert
(()
{
throw
FlutterError
.
fromParts
(<
DiagnosticsNode
>[
ErrorSummary
(
'RenderObjectElement.removeChildRenderObject() is deprecated.'
),
toDiagnosticsNode
(
name:
'super.removeChildRenderObject() was called on this Element'
,
style:
DiagnosticsTreeStyle
.
shallow
,
),
ErrorDescription
(
'removeChildRenderObject() has been deprecated in favor of '
'removeRenderObjectChild(). See https://github.com/flutter/flutter/issues/63269 '
'for details.'
,
),
ErrorHint
(
'Rather than overriding removeChildRenderObject() in your '
'RenderObjectElement subclass, override removeRenderObjectChild() instead, '
"and DON'T call super.removeRenderObjectChild(). If you're implementing a "
'new RenderObjectElement, you should override/implement '
'insertRenderObjectChild(), moveRenderObjectChild(), and '
'removeRenderObjectChild().'
,
),
]);
}());
}
void
removeRenderObjectChild
(
covariant
RenderObject
child
,
covariant
Object
?
slot
);
@override
void
debugFillProperties
(
DiagnosticPropertiesBuilder
properties
)
{
...
...
packages/flutter/test/widgets/framework_test.dart
View file @
7f41ab25
...
...
@@ -2119,6 +2119,15 @@ class FakeLeafRenderObject extends RenderBox {
class
TestRenderObjectElement
extends
RenderObjectElement
{
TestRenderObjectElement
()
:
super
(
Table
());
@override
void
insertRenderObjectChild
(
covariant
RenderObject
child
,
covariant
Object
?
slot
)
{
}
@override
void
moveRenderObjectChild
(
covariant
RenderObject
child
,
covariant
Object
?
oldSlot
,
covariant
Object
?
newSlot
)
{
}
@override
void
removeRenderObjectChild
(
covariant
RenderObject
child
,
covariant
Object
?
slot
)
{
}
}
class
_EmptyWidget
extends
Widget
{
...
...
packages/flutter/test/widgets/memory_allocations_test.dart
View file @
7f41ab25
...
...
@@ -66,6 +66,15 @@ class _TestElement extends RootRenderObjectElement{
mount
(
null
,
null
);
deactivate
();
}
@override
void
insertRenderObjectChild
(
covariant
RenderObject
child
,
covariant
Object
?
slot
)
{
}
@override
void
moveRenderObjectChild
(
covariant
RenderObject
child
,
covariant
Object
?
oldSlot
,
covariant
Object
?
newSlot
)
{
}
@override
void
removeRenderObjectChild
(
covariant
RenderObject
child
,
covariant
Object
?
slot
)
{
}
}
class
_TestRenderObject
extends
RenderObject
{
...
...
packages/flutter/test/widgets/render_object_element_test.dart
View file @
7f41ab25
...
...
@@ -105,6 +105,15 @@ abstract class SwapperElement extends RenderObjectElement {
swapper
=
updateChild
(
swapper
,
widget
.
swapper
,
swapperIsOnTop
);
swapperIsOnTop
=
!
swapperIsOnTop
;
}
@override
void
insertRenderObjectChild
(
covariant
RenderObject
child
,
covariant
Object
?
slot
)
{
}
@override
void
moveRenderObjectChild
(
covariant
RenderObject
child
,
covariant
Object
?
oldSlot
,
covariant
Object
?
newSlot
)
{
}
@override
void
removeRenderObjectChild
(
covariant
RenderObject
child
,
covariant
Object
?
slot
)
{
}
}
class
SwapperElementWithProperOverrides
extends
SwapperElement
{
...
...
@@ -288,26 +297,4 @@ void main() {
expect
(
swapper
.
removeSlots
,
contains
(
'stable'
));
expect
(
swapper
.
removeSlots
,
contains
(
false
));
});
testWidgets
(
'RenderObjectElement *ChildRenderObject methods fail with deprecation message'
,
(
WidgetTester
tester
)
async
{
const
Key
redKey
=
ValueKey
<
String
>(
'red'
);
const
Key
blueKey
=
ValueKey
<
String
>(
'blue'
);
Widget
widget
()
{
return
SwapperWithNoOverrides
(
stable:
ColoredBox
(
key:
redKey
,
color:
Color
(
nonconst
(
0xffff0000
)),
),
swapper:
ColoredBox
(
key:
blueKey
,
color:
Color
(
nonconst
(
0xff0000ff
)),
),
);
}
await
tester
.
pumpWidget
(
widget
());
final
FlutterError
error
=
tester
.
takeException
()
as
FlutterError
;
final
ErrorSummary
summary
=
error
.
diagnostics
.
first
as
ErrorSummary
;
expect
(
summary
.
toString
(),
contains
(
'deprecated'
));
});
}
packages/flutter/test_release/widgets/memory_allocations_test.dart
View file @
7f41ab25
...
...
@@ -63,6 +63,15 @@ class _TestElement extends RootRenderObjectElement{
mount
(
null
,
null
);
deactivate
();
}
@override
void
insertRenderObjectChild
(
covariant
RenderObject
child
,
covariant
Object
?
slot
)
{
}
@override
void
moveRenderObjectChild
(
covariant
RenderObject
child
,
covariant
Object
?
oldSlot
,
covariant
Object
?
newSlot
)
{
}
@override
void
removeRenderObjectChild
(
covariant
RenderObject
child
,
covariant
Object
?
slot
)
{
}
}
class
_MyStatefulWidget
extends
StatefulWidget
{
...
...
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