moveSection method
void
moveSection(
- K sectionKey,
- int toIndex
)
Implementation
void moveSection(K sectionKey, int toIndex) {
_checkNotDisposed();
_requireSection(sectionKey, "moveSection");
if (_tree.isPendingDeletion(SectionKey<K>(sectionKey))) {
_throwMissing("moveSection", "section $sectionKey is being removed");
}
// Use the LIVE list — `reorderSections` → `_tree.reorderRoots`
// validates against the live root set (excludes pending-deletion).
// The previous full-list form would build a proposed order
// including pending-deletion siblings and trip the validation when
// a sibling section was mid-exit-animation.
final order = sectionKeys..remove(sectionKey);
final clamped = toIndex.clamp(0, order.length);
order.insert(clamped, sectionKey);
reorderSections(order);
}