moveChildRenderObject method Null safety

  1. @protected
  2. @mustCallSuper
  3. @Deprecated('Override moveRenderObjectChild instead. ' 'This feature was deprecated after v1.21.0-9.0.pre.')
void moveChildRenderObject(
  1. covariant RenderObject child,
  2. covariant Object? slot
@Deprecated('Override moveRenderObjectChild instead. ' 'This feature was deprecated after v1.21.0-9.0.pre.'), @mustCallSuper, @protected

Move the given child to the given slot.

The given child is guaranteed to have renderObject as its parent.

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.

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.


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(...).


  'Override moveRenderObjectChild instead. '
  'This feature was deprecated after v1.21.0-9.0.pre.',
void moveChildRenderObject(covariant RenderObject child, covariant Object? slot) {
  assert(() {
    throw FlutterError.fromParts(<DiagnosticsNode>[
      ErrorSummary('RenderObjectElement.moveChildRenderObject() is deprecated.'),
        name: 'super.moveChildRenderObject() was called on this Element',
        style: DiagnosticsTreeStyle.shallow,
        'moveChildRenderObject() has been deprecated in favor of '
        'moveRenderObjectChild(). See '
        'for details.',
        '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 '