insertChildRenderObject method Null safety

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

Insert the given child into renderObject at the given slot.

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.

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

Implementation

@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) {
  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().',
      ),
    ]);
  }());
}