repeating<T> static method

FrameNode repeating<T>({
  1. required List<T> over,
  2. required List<SceneNode> row(
    1. T item
    ),
  3. String name = '',
  4. double x = 0,
  5. double y = 0,
  6. double? width,
  7. double? height,
  8. SceneColor? fill,
  9. SceneColor? borderColor,
  10. double borderWidth = 1,
  11. double corner = 0,
  12. double opacity = 1,
  13. NodeLayout layout = NodeLayout.absolute,
  14. double gap = 8,
  15. double? padding,
  16. double? paddingLeft,
  17. double? paddingTop,
  18. double? paddingRight,
  19. double? paddingBottom,
  20. SceneMainAxisAlignment mainAlign = SceneMainAxisAlignment.start,
  21. SceneCrossAxisAlignment crossAlign = SceneCrossAxisAlignment.center,
})

A frame drawn once per item of over, its cells built by row.

A static rather than a constructor because it is GENERIC: T is the item type, inferred from the list, and that is what makes line.item checked rather than dynamic. The cast inside cannot fail — the list and the closure arrive together.

The frame's own children are the first item's cells, so the thing on screen and the thing in the file are the same row.

Implementation

static FrameNode repeating<T>({
  required List<T> over,
  required List<SceneNode> Function(T item) row,
  String name = '',
  double x = 0,
  double y = 0,
  double? width,
  double? height,
  SceneColor? fill,
  SceneColor? borderColor,
  double borderWidth = 1,
  double corner = 0,
  double opacity = 1,
  NodeLayout layout = NodeLayout.absolute,
  double gap = 8,
  double? padding,
  double? paddingLeft,
  double? paddingTop,
  double? paddingRight,
  double? paddingBottom,
  SceneMainAxisAlignment mainAlign = SceneMainAxisAlignment.start,
  SceneCrossAxisAlignment crossAlign = SceneCrossAxisAlignment.center,
}) => FrameNode(
  name: name,
  x: x,
  y: y,
  width: width,
  height: height,
  fill: fill,
  borderColor: borderColor,
  borderWidth: borderWidth,
  corner: corner,
  opacity: opacity,
  layout: layout,
  gap: gap,
  padding: padding,
  paddingLeft: paddingLeft,
  paddingTop: paddingTop,
  paddingRight: paddingRight,
  paddingBottom: paddingBottom,
  mainAlign: mainAlign,
  crossAlign: crossAlign,
  children: over.isEmpty ? const [] : row(over.first),
)..repeated = SceneRepeat(items: over, row: (item) => row(item as T));