layoutChild method

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

Lays out the child.

This is called by performLayout. It applies the given scrollOffset (which need not match the offset given by the constraints) and the maxExtent (which need not match the value returned by the maxExtent getter).

The overlapsContent argument is passed to updateChild.


void layoutChild(double scrollOffset, double maxExtent, { bool overlapsContent = false }) {
  assert(maxExtent != null);
  final double shrinkOffset = math.min(scrollOffset, maxExtent);
  if (_needsUpdateChild || _lastShrinkOffset != shrinkOffset || _lastOverlapsContent != overlapsContent) {
    invokeLayoutCallback<SliverConstraints>((SliverConstraints constraints) {
      assert(constraints == this.constraints);
      updateChild(shrinkOffset, overlapsContent);
    _lastShrinkOffset = shrinkOffset;
    _lastOverlapsContent = overlapsContent;
    _needsUpdateChild = false;
  assert(minExtent != null);
  assert(() {
    if (minExtent <= maxExtent)
      return true;
    throw FlutterError(
      'The maxExtent for this $runtimeType is less than its minExtent.\n'
      'The specified maxExtent was: ${maxExtent.toStringAsFixed(1)}\n'
      'The specified minExtent was: ${minExtent.toStringAsFixed(1)}\n'
    constraints.asBoxConstraints(maxExtent: math.max(minExtent, maxExtent - shrinkOffset)),
    parentUsesSize: true,