debugAssertDoesMeetConstraints method

  1. @override
void debugAssertDoesMeetConstraints()
override

Verify that the object's constraints are being met. Override this function in a subclass to verify that your state matches the constraints object. This function is only called when asserts are enabled (i.e. in debug mode) and only when needsLayout is false. If the constraints are not met, it should assert or throw an exception.

Implementation

@override
void debugAssertDoesMeetConstraints() {
  super.debugAssertDoesMeetConstraints();
  assert(() {
    if (itemExtentBuilder == null && geometry!.scrollExtent.isFinite) {
      final double itemExtent = this.itemExtent!;
      final double scrollExtent = geometry!.scrollExtent;
      final double count = scrollExtent / itemExtent;
      final double diff = (count.roundToDouble() - count).abs();
      if (diff * itemExtent > precisionErrorTolerance && diff > precisionErrorTolerance) {
        throw FlutterError.fromParts(<DiagnosticsNode>[
          ErrorSummary(
            'RenderSliverFixedExtentBoxAdaptor.computeMaxScrollOffset() returned a value that is not an even multiple of its itemExtent.',
          ),
          ErrorDescription(
            'The itemExtent was $itemExtent, but the scrollExtent was $scrollExtent.',
          ),
          ErrorDescription(
            'The difference was $diff, which is greater than precisionErrorTolerance ($precisionErrorTolerance).',
          ),
          describeForError('The render object in question was'),
        ]);
      }
    }
    return true;
  }());
}