debugAssertIsValid method Null safety
- {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 summary, {List<DiagnosticsNode>? details}) {
if (check) {
return;
}
throw FlutterError.fromParts(<DiagnosticsNode>[
ErrorSummary('${objectRuntimeType(this, 'SliverGeometry')} is not valid: $summary'),
...?details,
if (informationCollector != null)
...informationCollector(),
]);
}
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".',
details: _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 precisionErrorTolerance, we will not throw the assert below.
if (paintExtent - maxPaintExtent > precisionErrorTolerance) {
verify(false,
'The "maxPaintExtent" is less than the "paintExtent".',
details:
_debugCompareFloats('maxPaintExtent', maxPaintExtent, 'paintExtent', paintExtent)
..add(ErrorDescription("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;
}