splitVerticalByLargestRemainder function

({List<Rectangle> rows}) splitVerticalByLargestRemainder(
  1. Rectangle area,
  2. List<int> weights, {
  3. List<int> previousAllocations = const [],
})

Splits area into vertical segments using stable largest-remainder sizing.

Use previousAllocations to stabilize ties across consecutive layout frames.

Implementation

({List<Rectangle> rows}) splitVerticalByLargestRemainder(
  Rectangle area,
  List<int> weights, {
  List<int> previousAllocations = const [],
}) {
  final heights = splitByLargestRemainder(
    area.height,
    weights,
    previous: previousAllocations,
  );

  var y = area.minY;
  final rows = <Rectangle>[];
  for (final height in heights) {
    rows.add(
      Rectangle(minX: area.minX, minY: y, maxX: area.maxX, maxY: y + height),
    );
    y += height;
  }

  return (rows: rows);
}