addItem method
Inserts item under toSection at index (or at the end).
Implementation
void addItem(
Item item, {
required K toSection,
int? index,
bool animate = true,
}) {
_checkNotDisposed();
_requireSection(toSection, "addItem");
// Scoped to OTHER sections: re-adding into `toSection` is either the
// cancel-deletion path for a mid-exit item or an in-section upsert,
// both of which `insert` handles.
_requireItemsFree(
[itemKeyOf(item)],
"addItem",
exceptInSection: toSection,
);
_tree.insert(
parentKey: SectionKey<K>(toSection),
node: TreeNode(
key: ItemKey<K>(itemKeyOf(item)),
data: ItemPayload<Section, Item>(item),
),
index: index,
animate: animate,
);
}