SectionedListController<SKey, IKey, Section, Item> class

Controller for a SectionedSliverList.

Owns the imperative API (addItem, moveItem, setItems, expandSection, ...). When supplied to a SectionedSliverList via the optional controller parameter, the widget binds to it and drives it from its declarative sections / grouped input. Users can also call mutating methods between widget rebuilds to drift state outside the declarative source — but the next widget rebuild with a different sections value re-syncs to that input (the "source of truth on rebuild" rule).

Lifetime: must be disposed by the owner. If you do not pass an external controller to the widget, the widget creates one internally and disposes it for you. If you do pass one, you keep it across rebuilds and call dispose yourself when finished.

A controller is designed to drive exactly one widget at a time. Mounting two widgets against the same controller asserts in debug.

Constructors

SectionedListController({required TickerProvider vsync, Duration animationDuration = const Duration(milliseconds: 300), Curve animationCurve = Curves.easeInOut, bool preserveExpansion = true})

Properties

animationCurve Curve
no getter
animationDuration Duration
Animation params and preserveExpansion may be mutated by an internally-owned widget propagating its widget.animationDuration etc. across rebuilds. External controllers are authoritative for these and the widget refuses to overwrite them.
no getter
hashCode int
The hash code for this object.
no setterinherited
liveSections List<SKey>
Section keys in render order, EXCLUDING sections currently mid- exit-animation. Returns [] when no live sections exist.
no setter
preserveExpansion bool
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sections List<SKey>
Section keys in render order. Returns [] when empty.
no setter
treeController TreeController<SecKey<SKey, IKey>, SecPayload<Section, Item>>
Underlying tree controller. Exposed for the widget's render layer (it must construct a SliverTree against this). Not part of the supported public API for end users — calling structural methods directly on the underlying tree bypasses the section/item type invariants this controller enforces.
no setter

Methods

addItem(SKey sectionKey, ItemInput<IKey, Item> item, {int? index, bool animate = true}) → void
addSection(SectionInput<SKey, IKey, Section, Item> section, {int? index, bool animate = true}) → void
collapseAll({bool animate = true}) → void
collapseSection(SKey key, {bool animate = true}) → void
debugBindWidget() → void
Marks this controller as bound to a widget. Asserts that no other widget is currently bound. Called by SectionedSliverListState during initState and after a controller swap.
debugSnapshotCurrentChildren() Map<SKey, List<IKey>>
Snapshots used by the widget's initial-expansion logic (mirrors the existing public hooks on TreeSyncController).
debugSnapshotRememberedSectionKeys() Set<SKey>
debugUnbindWidget() → void
Releases the binding established by debugBindWidget. Called by SectionedSliverListState during dispose and before a controller swap.
dispose() → void
expandAll({bool animate = true}) → void
expandSection(SKey key, {bool animate = true}) → void
getItem(IKey key) → Item?
getSection(SKey key) → Section?
hasItem(IKey key) bool
hasSection(SKey key) bool
indexOfItem(IKey itemKey) int
Position of itemKey among its section's children in live-list space (skipping pending-deletion siblings). Returns -1 when itemKey is not present, is itself pending-deletion, or is not an item.
isExpanded(SKey key) bool
itemCount(SKey sectionKey) int
Number of items currently belonging to sectionKey, regardless of expansion state. Returns 0 for unknown sections.
itemsOf(SKey sectionKey) List<IKey>
Item keys for sectionKey in render order. Returns [] when the section does not exist or has no items — call hasSection to disambiguate if needed.
liveItemsOf(SKey sectionKey) List<IKey>
Item keys for sectionKey in render order, EXCLUDING items currently mid-exit-animation. Returns [] when no live items exist (or the section is unknown).
moveItem(IKey key, {required SKey toSection, int? index}) → void
moveItemInSection(IKey key, int toIndex) → void
moveSection(SKey key, int toIndex) → void
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeItem(IKey key, {bool animate = true}) → void
removeSection(SKey key, {bool animate = true}) → void
reorderItems(SKey sectionKey, List<IKey> orderedKeys) → void
reorderSections(List<SKey> orderedKeys) → void
runBatch<T>(T body()) → T
Coalesces structural notifications across the mutations performed inside body into a single post-batch refresh. Delegates to the underlying TreeController.runBatch.
sectionOf(IKey key) → SKey?
setItems(SKey sectionKey, Iterable<ItemInput<IKey, Item>> items, {bool animate = true}) → void
setSections(Iterable<SectionInput<SKey, IKey, Section, Item>> sections, {bool animate = true}) → void
Replaces all sections. Diffs against current state and animates inserts, removes, and reparenting.
toggleSection(SKey key, {bool animate = true}) → void
toString() String
A string representation of this object.
inherited
updateItem(IKey key, Item item) → void
updateSection(SKey key, Section section) → void

Operators

operator ==(Object other) bool
The equality operator.
inherited