wrapWithDivider static method

List<PullDownMenuEntry> wrapWithDivider(
  1. List<PullDownMenuEntry> items
)

Helper method that simplifies separation of pull-down menu items.

Implementation

static List<PullDownMenuEntry> wrapWithDivider(
  List<PullDownMenuEntry> items,
) {
  if (items.isEmpty || items.length == 1) {
    return items;
  }

  const divider = PullDownMenuDivider();

  return [
    for (final i in items.take(items.length - 1)) ...[i, divider],
    items.last,
  ];
}