debugCannotComputeDryLayout method

bool debugCannotComputeDryLayout(
  1. {String? reason,
  2. FlutterError? error}
)

Called from computeDryLayout within an assert if the given RenderBox subclass does not support calculating a dry layout.

When asserts are enabled and debugCheckingIntrinsics is not true, this method will either throw the provided FlutterError or it will create and throw a FlutterError with the provided reason. Otherwise, it will return true.

One of the arguments has to be provided.

See also:

  • computeDryLayout, which lists some reasons why it may not be feasible to compute the dry layout.

Implementation

bool debugCannotComputeDryLayout({String? reason, FlutterError? error}) {
  assert((reason == null) != (error == null));
  assert(() {
    if (!RenderObject.debugCheckingIntrinsics) {
      if (reason != null) {
        assert(error ==null);
        throw FlutterError.fromParts(<DiagnosticsNode>[
          ErrorSummary('The ${objectRuntimeType(this, 'RenderBox')} class does not support dry layout.'),
          if (reason.isNotEmpty) ErrorDescription(reason),
        ]);
      }
      assert(error != null);
      throw error!;
    }
    _dryLayoutCalculationValid = false;
    return true;
  }());
  return true;
}