collection_notifiers 2.4.0
collection_notifiers: ^2.4.0 copied to clipboard
Reactive List, Set, Map and Queue for Flutter — mutate in place, notify only on real change. A flutter_hooks hook per type (useListNotifier) plus a ValueListenable fallback.
Changelog #
2.4.0 - 2026-10-04 #
Added #
batch(body)on every notifier: one notification per batch, silent when no inner call changed anything.assignAll(...)on every notifier: replaces the contents with one notification, silent when equal.ListNotifier.move(from, to): always moves the element; notifies once, or not at all when the contents are unchanged by==. Use it asReorderableListView(onReorderItem: list.move).- Notifiers report their creation to
FlutterMemoryAllocations, so leak_tracker sees notifiers that are never listened to.
Changed #
- Requires Dart 3.13 / Flutter 3.47 (was Dart 3.10).
- Behaviour change:
ListNotifier[]=/first=/last=andMapNotifier[]=always store the new value and notify only whenold != new. An equal-but-distinct value (id-only==,-0.0over0.0) was silently dropped; this reverses the 2.0.2 "no write-back" change. - Mutating a disposed notifier fails in debug mode before the mutation, including no-op calls.
ListNotifier.sortis silent when the list is already sorted.- The agent skill moved to
skills/collection-notifiers-usage/(wasskills/flutter-collection-notifiers/), sodart run skills@ get --package collection_notifiers --allinstalls it.
Fixed #
ListNotifier.insertAllandQueueNotifier.addAllnotify for lazy iterables that empty themselves while being added.- Lazy iterables are read once in
addAll,insertAll,replaceRangeandQueueNotifier.addAll. MapNotifier.updatenotifies whenifAbsentadds anullvalue.ListNotifier.setRangerejects a negativeskipCountwith aRangeError, likeList.- Bulk mutators notify when a callback or iterable throws after a partial change.
cast()views (andretype()frompackage:collection) notify when mutated.ListNotifier.addAllwith the notifier itself throwsConcurrentModificationErrorbefore changing anything, likeList; it used to append one element and notify first.- Example: the ValueListenableBuilder panels refresh their buttons, and Map "Add item" always adds a row.
- Docs:
addEntriesis no longer described as length-only, hookkeysis documented, the Riverpod 3 snippet importsflutter_riverpod.dartandlegacy.dart, and every snippet compiles.
Removed #
homepageanddocumentationfrompubspec.yaml.- The Codecov badge and
codecov.yml. SECURITY.md(no private vulnerability-report channel).
2.3.1 #
- fix: enforced transactional boundaries for
ListNotifier.setAllandListNotifier.setRangeby verifying target lengths before executing in-place mutations. - fix: wrapped
MapNotifier.updateAlliteration in atry/finallyblock to guaranteenotifyListenersfires even if the user-provided update callback throws midway.
2.3.0 #
- feat: added optional
keysdependency array to all hooks (useListNotifier,useMapNotifier,useSetNotifier,useQueueNotifier) for keys-based state resets without unmounting the host widget. - feat: overrode
notifyListenersas public on all notifiers to support manual UI updates on deep/in-place collection mutations. - fix: fixed
MapNotifier.addEntriessilent update bug by checking entry-by-entry for key addition or value modification. - perf: optimized range updates in
ListNotifier.setAll,setRange, andreplaceRangeto compare in-place and only notify on actual content changes. - docs: README rewritten for pith and consistency with sibling packages (
fluiver,rand). Removed decorative emojis and marketing voice; restructured into per-concern sections with a pitfalls table.
2.2.0 #
- feat: ship dedicated
flutter_hookshooks for every notifier —useListNotifier,useSetNotifier,useMapNotifier,useQueueNotifier. Each owns the lifecycle: creates on first build, disposes on unmount, rebuilds the host widget on every mutation. - feat:
flutter_hooksis now a runtime dependency. - docs: agent skill at
skills/flutter-collection-notifiers/SKILL.mdreplaces the oldrules/collection_notifiers.md. - docs: stronger "hooks recommended" framing in the library dartdoc;
method-level notes on
ListNotifier.sort/shuffle(always notify whenlength > 1) andMapNotifier.addEntries(length-only check). - docs: shallow-copy semantics called out on every notifier constructor.
- example: each tab now shows a hooks panel (
useXNotifier, self-contained) alongside the externally-ownedValueListenableBuilderpanel. - test: widget tests for all four hooks covering single-instance reuse,
dispose-on-unmount, rebuild-on-mutation, and one-time
initialsemantics.
2.1.0 #
- feat:
ListNotifiernow notifies listeners for thelength=,first=, andlast=setters. Previously these inherited fromDelegatingListand mutated silently. If you depend on silence here, audit call sites.
2.0.2 (not published) #
- fix:
ListNotifier.fillRangenow runsRangeError.checkValidRangebefore thefillValuecast and short-circuits on empty ranges, so an empty no-op call no longer crashes whenfillValueis omitted. - fix:
MapNotifier.addAllno longer skips notification when a new key is added with anullvalue (false-negative onsuper[key] != valuefor absent keys with null defaults). - fix:
ListNotifier.operator []=andMapNotifier.operator []=no longer write the same value back when the value is unchanged. - fix:
MapNotifier.putIfAbsentreturns the value from the underlyingputIfAbsentcall instead of re-reading viasuper[key]!. - test: expanded coverage with dispose semantics,
removeListener, re-entrant listener mutation, null-element handling, andValueListenableBuilderrebuild integration. - chore: added
issue_trackertopubspec.yaml.
2.0.1 #
- docs: Promoted
flutter_hooksas the recommended pattern. - docs: Fixed version migration documentation and cleaned up README.
2.0.0 #
- Breaking:
SetNotifier.invert()now returnstruewhen added,falsewhen removed. - fix:
QueueNotifier.add()not triggering notifications. - fix:
ListNotifiernotification logic forreplaceRange()andsetRange(). - docs: Enhanced example app and test suite.
- chore: Dart 3 upgrade and lint updates.
1.1.0 #
- Dart 3 upgrade
- Removed dependency constraints
- Updated lints with code reformat
1.0.5 #
MapNotifier.addAlllength-based comparison fixMapNotifier,ListNotifieroperators improvements- Support for wider range of dependencies
1.0.4 #
SetNotifier.invert(element)method added
1.0.3 #
- improved docs
- version bumps
- simplified example
1.0.2 #
lengthbasedMapNotifier.addAll/addEntries()check- test improvements
1.0.1 #
- Better null value handling in
MapNotifier - Diff calculation in
SetNotifier's batch operations nowlengthbased
1.0.0+1 #
- Doc and CI improvements
1.0.0 #
- Initial Release with
Set,Map,ListandQueuesupport