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
66826e8f
Unverified
Commit
66826e8f
authored
Mar 07, 2022
by
Kate Lovett
Committed by
GitHub
Mar 07, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove deprecated RenderObjectElement methods (#98616)
parent
a491a81f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
202 deletions
+12
-202
framework.dart
packages/flutter/lib/src/widgets/framework.dart
+12
-116
render_object_element_test.dart
...ages/flutter/test/widgets/render_object_element_test.dart
+0
-86
No files found.
packages/flutter/lib/src/widgets/framework.dart
View file @
66826e8f
...
...
@@ -6053,31 +6053,14 @@ abstract class RenderObjectElement extends Element {
/// Insert the given child into [renderObject] at the given slot.
///
/// {@macro flutter.widgets.RenderObjectElement.insertRenderObjectChild}
///
/// ## Deprecation
///
/// This method has been deprecated in favor of [insertRenderObjectChild].
///
/// The reason for the deprecation is to provide the `oldSlot` argument to
/// the [moveRenderObjectChild] method (such an argument was missing from
/// the now-deprecated [moveChildRenderObject] method) and the `slot`
/// argument to the [removeRenderObjectChild] method (such an argument was
/// missing from the now-deprecated [removeChildRenderObject] method). While
/// no argument was added to [insertRenderObjectChild], the name change (and
/// corresponding deprecation) was made to maintain naming parity with the
/// other two methods.
///
/// To migrate, simply override [insertRenderObjectChild] instead of
/// [insertChildRenderObject]. The arguments stay the same. Subclasses should
/// _not_ call `super.insertRenderObjectChild(...)`.
/// {@template flutter.widgets.RenderObjectElement.insertRenderObjectChild}
/// The semantics of `slot` are determined by this element. For example, if
/// this element has a single child, the slot should always be null. If this
/// element has a list of children, the previous sibling element wrapped in an
/// [IndexedSlot] is a convenient value for the slot.
/// {@endtemplate}
@protected
@mustCallSuper
@Deprecated
(
'Override insertRenderObjectChild instead. '
'This feature was deprecated after v1.21.0-9.0.pre.'
,
)
void
insertChildRenderObject
(
covariant
RenderObject
child
,
covariant
Object
?
slot
)
{
void
insertRenderObjectChild
(
covariant
RenderObject
child
,
covariant
Object
?
slot
)
{
assert
(()
{
throw
FlutterError
.
fromParts
(<
DiagnosticsNode
>[
ErrorSummary
(
'RenderObjectElement.insertChildRenderObject() is deprecated.'
),
...
...
@@ -6102,20 +6085,7 @@ abstract class RenderObjectElement extends Element {
}());
}
/// Insert the given child into [renderObject] at the given slot.
///
/// {@template flutter.widgets.RenderObjectElement.insertRenderObjectChild}
/// The semantics of `slot` are determined by this element. For example, if
/// this element has a single child, the slot should always be null. If this
/// element has a list of children, the previous sibling element wrapped in an
/// [IndexedSlot] is a convenient value for the slot.
/// {@endtemplate}
@protected
void
insertRenderObjectChild
(
covariant
RenderObject
child
,
covariant
Object
?
slot
)
{
insertChildRenderObject
(
child
,
slot
);
}
/// Move the given child to the given slot.
/// Move the given child from the given old slot to the given new slot.
///
/// The given child is guaranteed to have [renderObject] as its parent.
///
...
...
@@ -6129,32 +6099,8 @@ abstract class RenderObjectElement extends Element {
/// always having the same slot (and where children in different slots are never
/// compared against each other for the purposes of updating one slot with the
/// element from another slot) would never call this.
///
/// ## Deprecation
///
/// This method has been deprecated in favor of [moveRenderObjectChild].
///
/// The reason for the deprecation is to provide the `oldSlot` argument to
/// the [moveRenderObjectChild] method (such an argument was missing from
/// the now-deprecated [moveChildRenderObject] method) and the `slot`
/// argument to the [removeRenderObjectChild] method (such an argument was
/// missing from the now-deprecated [removeChildRenderObject] method). While
/// no argument was added to [insertRenderObjectChild], the name change (and
/// corresponding deprecation) was made to maintain naming parity with the
/// other two methods.
///
/// To migrate, simply override [moveRenderObjectChild] instead of
/// [moveChildRenderObject]. The `slot` argument becomes the `newSlot`
/// argument, and the method will now take a new `oldSlot` argument that
/// subclasses may find useful. Subclasses should _not_ call
/// `super.moveRenderObjectChild(...)`.
@protected
@mustCallSuper
@Deprecated
(
'Override moveRenderObjectChild instead. '
'This feature was deprecated after v1.21.0-9.0.pre.'
,
)
void
moveChildRenderObject
(
covariant
RenderObject
child
,
covariant
Object
?
slot
)
{
void
moveRenderObjectChild
(
covariant
RenderObject
child
,
covariant
Object
?
oldSlot
,
covariant
Object
?
newSlot
)
{
assert
(()
{
throw
FlutterError
.
fromParts
(<
DiagnosticsNode
>[
ErrorSummary
(
'RenderObjectElement.moveChildRenderObject() is deprecated.'
),
...
...
@@ -6179,53 +6125,12 @@ abstract class RenderObjectElement extends Element {
}());
}
/// Move the given child from the given old slot to the given new slot.
///
/// The given child is guaranteed to have [renderObject] as its parent.
///
/// {@macro flutter.widgets.RenderObjectElement.insertRenderObjectChild}
///
/// This method is only ever called if [updateChild] can end up being called
/// with an existing [Element] child and a `slot` that differs from the slot
/// that element was previously given. [MultiChildRenderObjectElement] does this,
/// for example. [SingleChildRenderObjectElement] does not (since the `slot` is
/// always null). An [Element] that has a specific set of slots with each child
/// always having the same slot (and where children in different slots are never
/// 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
)
{
moveChildRenderObject
(
child
,
newSlot
);
}
/// Remove the given child from [renderObject].
///
/// The given child is guaranteed to have [renderObject] as its parent.
///
/// ## Deprecation
///
/// This method has been deprecated in favor of [removeRenderObjectChild].
///
/// The reason for the deprecation is to provide the `oldSlot` argument to
/// the [moveRenderObjectChild] method (such an argument was missing from
/// the now-deprecated [moveChildRenderObject] method) and the `slot`
/// argument to the [removeRenderObjectChild] method (such an argument was
/// missing from the now-deprecated [removeChildRenderObject] method). While
/// no argument was added to [insertRenderObjectChild], the name change (and
/// corresponding deprecation) was made to maintain naming parity with the
/// other two methods.
///
/// To migrate, simply override [removeRenderObjectChild] instead of
/// [removeChildRenderObject]. The method will now take a new `slot` argument
/// that subclasses may find useful. Subclasses should _not_ call
/// `super.removeRenderObjectChild(...)`.
/// The given child is guaranteed to have been inserted at the given `slot`
/// and have [renderObject] as its parent.
@protected
@mustCallSuper
@Deprecated
(
'Override removeRenderObjectChild instead. '
'This feature was deprecated after v1.21.0-9.0.pre.'
,
)
void
removeChildRenderObject
(
covariant
RenderObject
child
)
{
void
removeRenderObjectChild
(
covariant
RenderObject
child
,
covariant
Object
?
slot
)
{
assert
(()
{
throw
FlutterError
.
fromParts
(<
DiagnosticsNode
>[
ErrorSummary
(
'RenderObjectElement.removeChildRenderObject() is deprecated.'
),
...
...
@@ -6250,15 +6155,6 @@ abstract class RenderObjectElement extends Element {
}());
}
/// 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
)
{
removeChildRenderObject
(
child
);
}
@override
void
debugFillProperties
(
DiagnosticPropertiesBuilder
properties
)
{
super
.
debugFillProperties
(
properties
);
...
...
packages/flutter/test/widgets/render_object_element_test.dart
View file @
66826e8f
...
...
@@ -62,17 +62,6 @@ class SwapperWithNoOverrides extends Swapper {
SwapperElement
createElement
()
=>
SwapperElementWithNoOverrides
(
this
);
}
class
SwapperWithDeprecatedOverrides
extends
Swapper
{
const
SwapperWithDeprecatedOverrides
({
Key
?
key
,
Widget
?
stable
,
Widget
?
swapper
,
})
:
super
(
key:
key
,
stable:
stable
,
swapper:
swapper
);
@override
SwapperElement
createElement
()
=>
SwapperElementWithDeprecatedOverrides
(
this
);
}
abstract
class
SwapperElement
extends
RenderObjectElement
{
SwapperElement
(
Swapper
widget
)
:
super
(
widget
);
...
...
@@ -150,38 +139,6 @@ class SwapperElementWithNoOverrides extends SwapperElement {
SwapperElementWithNoOverrides
(
Swapper
widget
)
:
super
(
widget
);
}
class
SwapperElementWithDeprecatedOverrides
extends
SwapperElement
{
SwapperElementWithDeprecatedOverrides
(
Swapper
widget
)
:
super
(
widget
);
@override
// ignore: must_call_super
void
insertChildRenderObject
(
RenderBox
child
,
Object
?
slot
)
{
insertSlots
.
add
(
slot
);
assert
(
child
!=
null
);
if
(
slot
==
'stable'
)
renderObject
.
stable
=
child
;
else
renderObject
.
setSwapper
(
child
,
slot
!
as
bool
);
}
@override
// ignore: must_call_super
void
moveChildRenderObject
(
RenderBox
child
,
bool
isOnTop
)
{
moveSlots
.
add
(
Pair
<
bool
>(
null
,
isOnTop
));
renderObject
.
setSwapper
(
child
,
isOnTop
);
}
@override
// ignore: must_call_super
void
removeChildRenderObject
(
RenderBox
child
)
{
removeSlots
.
add
(
null
);
if
(
child
==
renderObject
.
_stable
)
renderObject
.
stable
=
null
;
else
renderObject
.
setSwapper
(
null
,
swapperIsOnTop
);
}
}
class
RenderSwapper
extends
RenderBox
{
RenderBox
?
_stable
;
RenderBox
?
get
stable
=>
_stable
;
...
...
@@ -321,49 +278,6 @@ void main() {
expect
(
swapper
.
removeSlots
,
contains
(
false
));
});
testWidgets
(
'RenderObjectElement *RenderObjectChild methods delegate to deprecated methods'
,
(
WidgetTester
tester
)
async
{
const
Key
redKey
=
ValueKey
<
String
>(
'red'
);
const
Key
blueKey
=
ValueKey
<
String
>(
'blue'
);
Widget
widget
()
{
return
SwapperWithDeprecatedOverrides
(
stable:
ColoredBox
(
key:
redKey
,
color:
Color
(
nonconst
(
0xffff0000
)),
),
swapper:
ColoredBox
(
key:
blueKey
,
color:
Color
(
nonconst
(
0xff0000ff
)),
),
);
}
await
tester
.
pumpWidget
(
widget
());
final
SwapperElement
swapper
=
tester
.
element
<
SwapperElement
>(
find
.
byType
(
SwapperWithDeprecatedOverrides
));
final
RenderBox
redBox
=
tester
.
renderObject
<
RenderBox
>(
find
.
byKey
(
redKey
));
final
RenderBox
blueBox
=
tester
.
renderObject
<
RenderBox
>(
find
.
byKey
(
blueKey
));
expect
(
swapper
.
insertSlots
.
length
,
2
);
expect
(
swapper
.
insertSlots
,
contains
(
'stable'
));
expect
(
swapper
.
insertSlots
,
contains
(
true
));
expect
(
swapper
.
moveSlots
,
isEmpty
);
expect
(
swapper
.
removeSlots
,
isEmpty
);
expect
(
parentDataFor
(
redBox
).
offset
,
const
Offset
(
0
,
300
));
expect
(
parentDataFor
(
blueBox
).
offset
,
Offset
.
zero
);
await
tester
.
pumpWidget
(
widget
());
expect
(
swapper
.
insertSlots
.
length
,
2
);
expect
(
swapper
.
moveSlots
.
length
,
1
);
expect
(
swapper
.
moveSlots
,
contains
(
const
Pair
<
bool
>(
null
,
false
)));
expect
(
swapper
.
removeSlots
,
isEmpty
);
expect
(
parentDataFor
(
redBox
).
offset
,
Offset
.
zero
);
expect
(
parentDataFor
(
blueBox
).
offset
,
const
Offset
(
0
,
300
));
await
tester
.
pumpWidget
(
const
SwapperWithDeprecatedOverrides
());
expect
(
redBox
.
attached
,
false
);
expect
(
blueBox
.
attached
,
false
);
expect
(
swapper
.
insertSlots
.
length
,
2
);
expect
(
swapper
.
moveSlots
.
length
,
1
);
expect
(
swapper
.
removeSlots
.
length
,
2
);
expect
(
swapper
.
removeSlots
,
<
bool
?>[
null
,
null
]);
});
testWidgets
(
'RenderObjectElement *ChildRenderObject methods fail with deprecation message'
,
(
WidgetTester
tester
)
async
{
const
Key
redKey
=
ValueKey
<
String
>(
'red'
);
const
Key
blueKey
=
ValueKey
<
String
>(
'blue'
);
...
...
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