layoutChild method

  1. @protected
void layoutChild(
  1. double scrollOffset,
  2. double maxExtent, {
  3. bool overlapsContent = false,
})

Implementation

@protected
void layoutChild(double scrollOffset, double maxExtent,
    {bool overlapsContent = false}) {
  final double shrinkOffset = math.min(scrollOffset, maxExtent);
  if (_needsUpdateChild ||
      _lastShrinkOffset != shrinkOffset ||
      _lastOverlapsContent != overlapsContent) {
    invokeLayoutCallback<SliverConstraints>((SliverConstraints constraints) {
      assert(constraints == this.constraints);
      updateChild(shrinkOffset, minExtent, maxExtent, overlapsContent);
    });
    _lastShrinkOffset = shrinkOffset;
    _lastOverlapsContent = overlapsContent;
    _needsUpdateChild = false;
  }

  assert(() {
    if (minExtent <= maxExtent) {
      return true;
    }
    throw FlutterError.fromParts(<DiagnosticsNode>[
      ErrorSummary(
          'The maxExtent for this $runtimeType is less than its minExtent.'),
      DoubleProperty('The specified maxExtent was', maxExtent),
      DoubleProperty('The specified minExtent was', minExtent),
    ]);
  }());

  child?.layout(
    constraints.asBoxConstraints(
        maxExtent: math.max(minExtent, maxExtent - shrinkOffset)),
    parentUsesSize: true,
  );
}