sectioned_sliver_list/sectioned_sliver_list_widget library

Header + items convenience sliver, built on top of SliverTree.

Models a strict 2-level structure (sections containing items, items have no children) with separate types and builders for each level, animated insert/remove/reparent, sticky headers, and an optional external controller.

Type parameters: <SKey, IKey, Section, Item>. Section and item key domains are kept disjoint internally even when SKey == IKey. For readability you can alias at the call site:

typedef MySectionedList = SectionedSliverList<String, String, Folder, File>;

Two constructors:

  • default — declarative SectionInput list:

    SectionedSliverList<String, String, Folder, File>(
      sections: [
        SectionInput(key: 'docs', section: docsFolder, items: [...]),
        SectionInput(key: 'pics', section: picsFolder, items: [...]),
      ],
      headerBuilder: (ctx, s) => FolderHeader(s.section),
      itemBuilder: (ctx, i) => FileTile(i.item),
    )
    
  • .grouped — from Map<Section, List<Item>>:

    SectionedSliverList.grouped(
      sections: files.groupListsBy((f) => f.folder),
      sectionKeyOf: (folder) => folder.id,
      itemKeyOf: (file) => file.id,
      headerBuilder: ..., itemBuilder: ...,
    )
    

Source-of-truth rule: when both sections and controller are supplied, the prop is authoritative on every rebuild — controller mutations between rebuilds persist, but a parent rebuild with new sections re-diffs against that new value (matches TextField semantics with TextEditingController).

Classes

SectionedSliverList<SKey, IKey, Section, Item>
SectionedSliverListState<SKey, IKey, Section, Item>

Typedefs

SectionHeaderBuilder<SKey, IKey, Section, Item> = Widget Function(BuildContext context, SectionView<SKey, IKey, Section, Item> view)
Builds a header widget for a visible section.
SectionItemBuilder<SKey, IKey, Section, Item> = Widget Function(BuildContext context, ItemView<SKey, IKey, Section, Item> view)
Builds a row widget for a visible item.