updateSection method

void updateSection(
  1. K sectionKey,
  2. Section section
)

Updates sectionKey's payload to section without touching the section's items. Asserts that sectionKey already exists.

The key is taken explicitly rather than inferred from sectionKeyOf(section) so that a copy-with that nudges the id field surfaces as a missing-key assertion instead of silently corrupting the tree.

Implementation

void updateSection(K sectionKey, Section section) {
  _checkNotDisposed();
  _requireSection(sectionKey, "updateSection");
  _tree.updateNode(
    TreeNode(
      key: SectionKey<K>(sectionKey),
      data: SectionPayload<Section, Item>(section),
    ),
  );
}