separated static method

List<Widget> separated({
  1. required List<Widget> items,
})

Add a StreamContextMenuSeparator between each action in the given items.

If items is empty or contains a single element, no separators are added. The result can be passed directly to StreamContextMenu.new's children parameter.

{@tool snippet}

StreamContextMenu(
  children: StreamContextMenuAction.separated(
    items: [
      StreamContextMenuAction(label: Text('Reply')),
      StreamContextMenuAction(label: Text('Copy')),
      StreamContextMenuAction(label: Text('Delete')),
    ],
  ),
)

{@end-tool}

See also:

Implementation

static List<Widget> separated({
  required List<Widget> items,
}) {
  return [
    for (final (index, child) in items.indexed) ...[
      if (index > 0) const StreamContextMenuSeparator(),
      child,
    ],
  ];
}