performLayout method

  1. @override
void performLayout(
  1. Size size
)
override

Override this method to lay out and position all children given this widget's size.

This method must call layoutChild for each child. It should also specify the final position of each child with positionChild.

Implementation

@override
void performLayout(Size size) {
  if (cellIds.isEmpty) return;

  final hScroll = hOffset?.value ?? 0.0;
  final vScroll = vOffset.value;

  for (final id in cellIds) {
    if (!hasChild(id)) continue;
    final span = columnSpans[id.column];
    if (span == null) continue;

    final x = span.x - hScroll + pinnedWidth;
    final y = id.row * rowHeight - vScroll;

    // Tight constraints make each cell its own relayout boundary, so an
    // invalidation inside one cell can't dirty the whole quadrant.
    layoutChild(id, BoxConstraints.tight(Size(span.width, rowHeight)));
    positionChild(id, Offset(x, y));
  }
}