moveItemInSection method
void
moveItemInSection(
- K itemKey,
- int toIndex
)
Implementation
void moveItemInSection(K itemKey, int toIndex) {
_checkNotDisposed();
_requireItem(itemKey, "moveItemInSection");
if (_tree.isPendingDeletion(ItemKey<K>(itemKey))) {
_throwMissing("moveItemInSection", "item $itemKey is being removed");
}
final parentKey = sectionOf(itemKey);
if (parentKey == null) {
_throwMissing("moveItemInSection", "item $itemKey has no parent section");
}
// Use the LIVE list — `reorderItems` → `_tree.reorderChildren`
// validates against the live child set (excludes pending-deletion).
final siblings = itemKeysOf(parentKey)..remove(itemKey);
final clamped = toIndex.clamp(0, siblings.length);
siblings.insert(clamped, itemKey);
reorderItems(parentKey, siblings);
}