debugAssertIsValid method

bool debugAssertIsValid ({InformationCollector informationCollector })

Asserts that this geometry is internally consistent.

Does nothing if asserts are disabled. Always returns true.

Implementation

bool debugAssertIsValid({
  InformationCollector informationCollector,
}) {
  assert(() {
    void verify(bool check, String message) {
      if (check)
        return;
      final StringBuffer information = StringBuffer();
      if (informationCollector != null)
        informationCollector(information);
      throw FlutterError('$runtimeType is not valid: $message\n$information');
    }
    verify(scrollExtent != null, 'The "scrollExtent" is null.');
    verify(scrollExtent >= 0.0, 'The "scrollExtent" is negative.');
    verify(paintExtent != null, 'The "paintExtent" is null.');
    verify(paintExtent >= 0.0, 'The "paintExtent" is negative.');
    verify(paintOrigin != null, 'The "paintOrigin" is null.');
    verify(layoutExtent != null, 'The "layoutExtent" is null.');
    verify(layoutExtent >= 0.0, 'The "layoutExtent" is negative.');
    verify(cacheExtent >= 0.0, 'The "cacheExtent" is negative.');
    if (layoutExtent > paintExtent) {
      verify(false,
        'The "layoutExtent" exceeds the "paintExtent".\n' +
        _debugCompareFloats('paintExtent', paintExtent, 'layoutExtent', layoutExtent),
      );
    }
    verify(maxPaintExtent != null, 'The "maxPaintExtent" is null.');
    // If the paintExtent is slightly more than the maxPaintExtent, but the difference is still less
    // than epsilon, we will not throw the assert below.
    if (paintExtent - maxPaintExtent > _epsilon) {
      verify(false,
        'The "maxPaintExtent" is less than the "paintExtent".\n' +
        _debugCompareFloats('maxPaintExtent', maxPaintExtent, 'paintExtent', paintExtent) +
        'By definition, a sliver can\'t paint more than the maximum that it can paint!'
      );
    }
    verify(hitTestExtent != null, 'The "hitTestExtent" is null.');
    verify(hitTestExtent >= 0.0, 'The "hitTestExtent" is negative.');
    verify(visible != null, 'The "visible" property is null.');
    verify(hasVisualOverflow != null, 'The "hasVisualOverflow" is null.');
    verify(scrollOffsetCorrection != 0.0, 'The "scrollOffsetCorrection" is zero.');
    return true;
  }());
  return true;
}