removeChildRenderObject method Null safety

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

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

Implementation

@protected
@mustCallSuper
@Deprecated(
  'Override removeRenderObjectChild instead. '
  'This feature was deprecated after v1.21.0-9.0.pre.',
)
void removeChildRenderObject(covariant RenderObject child) {
  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().',
      ),
    ]);
  }());
}