Skip to content

Commit 4d8934a

Browse files
authored
Re-apply "(insert|move|remove)ChildRenderObject Deprecation: Step 1 (#64189)" (#64254)
This reverts commit ce40de6. (this re-applies #64189 by reverting #64249)
1 parent ce40de6 commit 4d8934a

15 files changed

Lines changed: 629 additions & 85 deletions

‎packages/flutter/lib/src/cupertino/action_sheet.dart‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,13 +448,13 @@ class _CupertinoAlertRenderElement extends RenderObjectElement {
448448
}
449449

450450
@override
451-
void insertChildRenderObject(RenderObject child, _AlertSections slot) {
451+
void insertRenderObjectChild(RenderObject child, _AlertSections slot) {
452452
_placeChildInSlot(child, slot);
453453
}
454454

455455
@override
456-
void moveChildRenderObject(RenderObject child, _AlertSections slot) {
457-
_placeChildInSlot(child, slot);
456+
void moveRenderObjectChild(RenderObject child, _AlertSections oldSlot, _AlertSections newSlot) {
457+
_placeChildInSlot(child, newSlot);
458458
}
459459

460460
@override
@@ -478,7 +478,7 @@ class _CupertinoAlertRenderElement extends RenderObjectElement {
478478
}
479479

480480
@override
481-
void removeChildRenderObject(RenderObject child) {
481+
void removeRenderObjectChild(RenderObject child, _AlertSections slot) {
482482
assert(child == renderObject.contentSection || child == renderObject.actionsSection);
483483
if (renderObject.contentSection == child) {
484484
renderObject.contentSection = null;

‎packages/flutter/lib/src/cupertino/dialog.dart‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ class _CupertinoDialogRenderElement extends RenderObjectElement {
433433
}
434434

435435
@override
436-
void insertChildRenderObject(RenderObject child, _AlertDialogSections slot) {
436+
void insertRenderObjectChild(RenderObject child, _AlertDialogSections slot) {
437437
assert(slot != null);
438438
switch (slot) {
439439
case _AlertDialogSections.contentSection:
@@ -446,7 +446,7 @@ class _CupertinoDialogRenderElement extends RenderObjectElement {
446446
}
447447

448448
@override
449-
void moveChildRenderObject(RenderObject child, _AlertDialogSections slot) {
449+
void moveRenderObjectChild(RenderObject child, _AlertDialogSections oldSlot, _AlertDialogSections newSlot) {
450450
assert(false);
451451
}
452452

@@ -470,7 +470,7 @@ class _CupertinoDialogRenderElement extends RenderObjectElement {
470470
}
471471

472472
@override
473-
void removeChildRenderObject(RenderObject child) {
473+
void removeRenderObjectChild(RenderObject child, _AlertDialogSections slot) {
474474
assert(child == renderObject.contentSection || child == renderObject.actionsSection);
475475
if (renderObject.contentSection == child) {
476476
renderObject.contentSection = null;

‎packages/flutter/lib/src/cupertino/text_selection.dart‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -775,10 +775,9 @@ class _CupertinoTextSelectionToolbarItemsElement extends RenderObjectElement {
775775
}
776776

777777
@override
778-
void insertChildRenderObject(RenderObject child, dynamic slot) {
778+
void insertRenderObjectChild(RenderObject child, dynamic slot) {
779779
if (slot is _CupertinoTextSelectionToolbarItemsSlot) {
780780
assert(child is RenderBox);
781-
assert(slot is _CupertinoTextSelectionToolbarItemsSlot);
782781
_updateRenderObject(child as RenderBox, slot);
783782
assert(renderObject.childToSlot.containsKey(child));
784783
assert(renderObject.slotToChild.containsKey(slot));
@@ -794,28 +793,30 @@ class _CupertinoTextSelectionToolbarItemsElement extends RenderObjectElement {
794793

795794
// This is not reachable for children that don't have an IndexedSlot.
796795
@override
797-
void moveChildRenderObject(RenderObject child, IndexedSlot<Element> slot) {
796+
void moveRenderObjectChild(RenderObject child, IndexedSlot<Element> oldSlot, IndexedSlot<Element> newSlot) {
798797
assert(child.parent == renderObject);
799-
renderObject.move(child as RenderBox, after: slot?.value?.renderObject as RenderBox);
798+
renderObject.move(child as RenderBox, after: newSlot?.value?.renderObject as RenderBox);
800799
}
801800

802801
static bool _shouldPaint(Element child) {
803802
return (child.renderObject.parentData as ToolbarItemsParentData).shouldPaint;
804803
}
805804

806805
@override
807-
void removeChildRenderObject(RenderObject child) {
806+
void removeRenderObjectChild(RenderObject child, dynamic slot) {
808807
// Check if the child is in a slot.
809-
if (renderObject.childToSlot.containsKey(child)) {
808+
if (slot is _CupertinoTextSelectionToolbarItemsSlot) {
810809
assert(child is RenderBox);
810+
assert(renderObject.slotToChild.containsKey(slot));
811811
assert(renderObject.childToSlot.containsKey(child));
812-
_updateRenderObject(null, renderObject.childToSlot[child]);
812+
_updateRenderObject(null, slot);
813813
assert(!renderObject.childToSlot.containsKey(child));
814814
assert(!renderObject.slotToChild.containsKey(slot));
815815
return;
816816
}
817817

818818
// Otherwise look for it in the list of children.
819+
assert(slot is IndexedSlot);
819820
assert(child.parent == renderObject);
820821
renderObject.remove(child as RenderBox);
821822
}

‎packages/flutter/lib/src/material/chip.dart‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2148,26 +2148,25 @@ class _RenderChipElement extends RenderObjectElement {
21482148
}
21492149

21502150
@override
2151-
void insertChildRenderObject(RenderObject child, dynamic slotValue) {
2151+
void insertRenderObjectChild(RenderObject child, _ChipSlot slot) {
21522152
assert(child is RenderBox);
2153-
assert(slotValue is _ChipSlot);
2154-
final _ChipSlot slot = slotValue as _ChipSlot;
21552153
_updateRenderObject(child, slot);
21562154
assert(renderObject.childToSlot.keys.contains(child));
21572155
assert(renderObject.slotToChild.keys.contains(slot));
21582156
}
21592157

21602158
@override
2161-
void removeChildRenderObject(RenderObject child) {
2159+
void removeRenderObjectChild(RenderObject child, _ChipSlot slot) {
21622160
assert(child is RenderBox);
2163-
assert(renderObject.childToSlot.keys.contains(child));
2164-
_updateRenderObject(null, renderObject.childToSlot[child]);
2161+
assert(renderObject.childToSlot[child] == slot);
2162+
assert(renderObject.slotToChild[slot] == child);
2163+
_updateRenderObject(null, slot);
21652164
assert(!renderObject.childToSlot.keys.contains(child));
21662165
assert(!renderObject.slotToChild.keys.contains(slot));
21672166
}
21682167

21692168
@override
2170-
void moveChildRenderObject(RenderObject child, dynamic slotValue) {
2169+
void moveRenderObjectChild(RenderObject child, dynamic oldSlot, dynamic newSlot) {
21712170
assert(false, 'not reachable');
21722171
}
21732172
}

‎packages/flutter/lib/src/material/input_decorator.dart‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,26 +1654,25 @@ class _RenderDecorationElement extends RenderObjectElement {
16541654
}
16551655

16561656
@override
1657-
void insertChildRenderObject(RenderObject child, dynamic slotValue) {
1657+
void insertRenderObjectChild(RenderObject child, _DecorationSlot slot) {
16581658
assert(child is RenderBox);
1659-
assert(slotValue is _DecorationSlot);
1660-
final _DecorationSlot slot = slotValue as _DecorationSlot;
16611659
_updateRenderObject(child as RenderBox, slot);
16621660
assert(renderObject.childToSlot.keys.contains(child));
16631661
assert(renderObject.slotToChild.keys.contains(slot));
16641662
}
16651663

16661664
@override
1667-
void removeChildRenderObject(RenderObject child) {
1665+
void removeRenderObjectChild(RenderObject child, _DecorationSlot slot) {
16681666
assert(child is RenderBox);
1669-
assert(renderObject.childToSlot.keys.contains(child));
1670-
_updateRenderObject(null, renderObject.childToSlot[child]);
1667+
assert(renderObject.childToSlot[child] == slot);
1668+
assert(renderObject.slotToChild[slot] == child);
1669+
_updateRenderObject(null, slot);
16711670
assert(!renderObject.childToSlot.keys.contains(child));
16721671
assert(!renderObject.slotToChild.keys.contains(slot));
16731672
}
16741673

16751674
@override
1676-
void moveChildRenderObject(RenderObject child, dynamic slotValue) {
1675+
void moveRenderObjectChild(RenderObject child, dynamic oldSlot, dynamic newSlot) {
16771676
assert(false, 'not reachable');
16781677
}
16791678
}

‎packages/flutter/lib/src/material/list_tile.dart‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,26 +1250,25 @@ class _ListTileElement extends RenderObjectElement {
12501250
}
12511251

12521252
@override
1253-
void insertChildRenderObject(RenderObject child, dynamic slotValue) {
1253+
void insertRenderObjectChild(RenderObject child, _ListTileSlot slot) {
12541254
assert(child is RenderBox);
1255-
assert(slotValue is _ListTileSlot);
1256-
final _ListTileSlot slot = slotValue as _ListTileSlot;
12571255
_updateRenderObject(child as RenderBox, slot);
12581256
assert(renderObject.childToSlot.keys.contains(child));
12591257
assert(renderObject.slotToChild.keys.contains(slot));
12601258
}
12611259

12621260
@override
1263-
void removeChildRenderObject(RenderObject child) {
1261+
void removeRenderObjectChild(RenderObject child, _ListTileSlot slot) {
12641262
assert(child is RenderBox);
1265-
assert(renderObject.childToSlot.keys.contains(child));
1266-
_updateRenderObject(null, renderObject.childToSlot[child]);
1263+
assert(renderObject.childToSlot[child] == slot);
1264+
assert(renderObject.slotToChild[slot] == child);
1265+
_updateRenderObject(null, slot);
12671266
assert(!renderObject.childToSlot.keys.contains(child));
12681267
assert(!renderObject.slotToChild.keys.contains(slot));
12691268
}
12701269

12711270
@override
1272-
void moveChildRenderObject(RenderObject child, dynamic slotValue) {
1271+
void moveRenderObjectChild(RenderObject child, dynamic oldSlot, dynamic newSlot) {
12731272
assert(false, 'not reachable');
12741273
}
12751274
}

‎packages/flutter/lib/src/widgets/binding.dart‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,19 +1268,19 @@ class RenderObjectToWidgetElement<T extends RenderObject> extends RootRenderObje
12681268
RenderObjectWithChildMixin<T> get renderObject => super.renderObject as RenderObjectWithChildMixin<T>;
12691269

12701270
@override
1271-
void insertChildRenderObject(RenderObject child, dynamic slot) {
1271+
void insertRenderObjectChild(RenderObject child, dynamic slot) {
12721272
assert(slot == _rootChildSlot);
12731273
assert(renderObject.debugValidateChild(child));
12741274
renderObject.child = child as T;
12751275
}
12761276

12771277
@override
1278-
void moveChildRenderObject(RenderObject child, dynamic slot) {
1278+
void moveRenderObjectChild(RenderObject child, dynamic oldSlot, dynamic newSlot) {
12791279
assert(false);
12801280
}
12811281

12821282
@override
1283-
void removeChildRenderObject(RenderObject child) {
1283+
void removeRenderObjectChild(RenderObject child, dynamic slot) {
12841284
assert(renderObject.child == child);
12851285
renderObject.child = null;
12861286
}

0 commit comments

Comments
 (0)