debugThrowIfNotCheckingIntrinsics method

  1. @override
bool debugThrowIfNotCheckingIntrinsics()
override

Throws an exception saying that the object does not support returning intrinsic dimensions if, in debug 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.fromParts(<DiagnosticsNode>[
        ErrorSummary('$runtimeType does not support returning intrinsic dimensions.'),
        ErrorDescription(
         'Calculating the intrinsic dimensions would require instantiating every child of '
         'the viewport, which defeats the point of viewports being lazy.',
        ),
        ErrorHint(
          '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;
}