allItems property

A list of all of the items displayed on this pane.

Implementation

List<NavigationPaneItem> get allItems {
  final all = items + footerItems;

  {
    final expandItems = LinkedList<_PaneItemExpanderItem>();
    for (final parent in all) {
      // We get all the [PaneItemExpander]s inside [all] items
      if (parent is PaneItemExpander) {
        // Them, we add them and their parent and siblings info to the
        // [expandItems]
        expandItems.addAll(parent.items.map(
          (expandItem) => _PaneItemExpanderItem(
            parent,
            expandItem,
            parent.items,
          ),
        ));
      }
    }

    // Now, we add them, in their respective position
    for (final entry in expandItems) {
      final parentIndex = all.indexOf(entry.parent);
      all.insert(
        parentIndex + 1 + entry.siblings.indexOf(entry.expanderItem),
        entry.expanderItem,
      );
    }
  }

  return all;
}