debugValidateChild method

bool debugValidateChild(
  1. RenderObject child
)

Checks whether the given render object has the correct runtimeType to be a child of this render object.

Does nothing if assertions are disabled.

Always returns true.

Implementation

bool debugValidateChild(RenderObject child) {
  assert(() {
    if (child is! ChildType) {
      throw FlutterError(
          'A $runtimeType expected a child of type $ChildType but received a '
          'child of type ${child.runtimeType}.\n'
          'RenderObjects expect specific types of children because they '
          'coordinate with their children during layout and paint. For '
          'example, a RenderSliver cannot be the child of a RenderBox because '
          'a RenderSliver does not understand the RenderBox layout protocol.\n'
          '\n'
          'The $runtimeType that expected a $ChildType child was created by:\n'
          '  $debugCreator\n'
          '\n'
          'The ${child.runtimeType} that did not match the expected child type '
          'was created by:\n'
          '  ${child.debugCreator}\n');
    }
    return true;
  }());
  return true;
}