watch method

Widget watch({
  1. required Widget builder(
    1. BuildContext context,
    2. SectionView<K, Section, Item> view
    ),
  2. Key? widgetKey,
})

Selectively rebuilds builder when this section's state changes:

  • expand/collapse
  • section payload (via controller.updateSection)
  • item count (items added or removed under this section)

The most common reason to use watch in a header is to keep a "X items" badge in sync as items churn under the section.

Implementation

Widget watch({
  required Widget Function(
    BuildContext context,
    SectionView<K, Section, Item> view,
  )
  builder,
  Key? widgetKey,
}) {
  return _SectionViewListener<K, Section, Item>(
    key: widgetKey,
    controller: controller,
    sectionKey: key,
    isCollapsible: isCollapsible,
    builder: builder,
  );
}