debugThrowIfNotCheckingIntrinsics method

  1. @protected
bool debugThrowIfNotCheckingIntrinsics ()
@protected

Throws an exception saying that the object does not support returning intrinsic dimensions if, in checked mode, we are not in the RenderObject.debugCheckingIntrinsics mode.

This is used by computeMinIntrinsicWidth et al because viewports do not generally support returning intrinsic dimensions. See the discussion at computeMinIntrinsicWidth.

Implementation

@protected
bool debugThrowIfNotCheckingIntrinsics() {
  assert(() {
    if (!RenderObject.debugCheckingIntrinsics) {
      assert(this is! RenderShrinkWrappingViewport); // it has its own message
      throw FlutterError(
        '$runtimeType does not support returning intrinsic dimensions.\n'
        'Calculating the intrinsic dimensions would require instantiating every child of '
        'the viewport, which defeats the point of viewports being lazy.\n'
        'If you are merely trying to shrink-wrap the viewport in the main axis direction, '
        'consider a RenderShrinkWrappingViewport render object (ShrinkWrappingViewport widget), '
        'which achieves that effect without implementing the intrinsic dimension API.'
      );
    }
    return true;
  }());
  return true;
}