buildForegroundFills function

List<Widget> buildForegroundFills(
  1. BaseNode node,
  2. ScopedValues scopedValues
)

fills clipped to node's notched outline when it has notches (fills are clipped even when the node doesn't clip its children), else fills.

A rectangle with a path (RectangleNode.path) fills the path instead. The DefaultShapeNode.foregroundFills of node, painted over its children inside its corners and notches (Flutter's foregroundDecoration): a translucent solid dims the whole box, text included. A solid's colour can be bound as foreground-<paint id>. They take no taps. Empty when the node has none.

Implementation

List<Widget> buildForegroundFills(BaseNode node, ScopedValues scopedValues) {
  if (node is! DefaultShapeNode || node.foregroundFills.isEmpty) return [];
  final BorderRadius? borderRadius = getBorderRadius(node);
  final List<Widget> layers = [
    for (final PaintModel paint in node.foregroundFills)
      if (paint.visible)
        if (_foregroundDecoration(node, paint, borderRadius, scopedValues)
            case final BoxDecoration decoration)
          Positioned.fill(child: DecoratedBox(decoration: decoration)),
  ];
  if (layers.isEmpty) return [];
  return [
    Positioned.fill(
      child: IgnorePointer(
        child: Stack(children: clipFillsToNotches(node, layers)),
      ),
    ),
  ];
}