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 in checked mode and only when needsLayout is false. If the constraints are not met, it should assert or throw an exception.

Implementation

@override
void debugAssertDoesMeetConstraints() {
  assert(geometry!.debugAssertIsValid(
    informationCollector: () => <DiagnosticsNode>[
      describeForError('The RenderSliver that returned the offending geometry was'),
    ],
  ));
  assert(() {
    if (geometry!.paintOrigin + geometry!.paintExtent > constraints.remainingPaintExtent) {
      throw FlutterError.fromParts(<DiagnosticsNode>[
        ErrorSummary('SliverGeometry has a paintOffset that exceeds the remainingPaintExtent from the constraints.'),
        describeForError('The render object whose geometry violates the constraints is the following'),
        ..._debugCompareFloats(
          'remainingPaintExtent', constraints.remainingPaintExtent,
          'paintOrigin + paintExtent', geometry!.paintOrigin + geometry!.paintExtent,
        ),
        ErrorDescription(
          'The paintOrigin and paintExtent must cause the child sliver to paint '
          'within the viewport, and so cannot exceed the remainingPaintExtent.',
        ),
      ]);
    }
    return true;
  }());
}