debugThrowIfNotCheckingIntrinsics method

  1. @override
bool debugThrowIfNotCheckingIntrinsics ()
override

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

@override
bool debugThrowIfNotCheckingIntrinsics() {
  assert(() {
    if (!RenderObject.debugCheckingIntrinsics) {
      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, '
        'you should be able to achieve that effect by just giving the viewport loose '
        'constraints, without needing to measure its intrinsic dimensions.'
      );
    }
    return true;
  }());
  return true;
}