Skip to content
Back to skills

Collection Notifiers Usage

ASecurity

Wire reactive List/Set/Map/Queue state in Flutter via `package:collection_notifiers` — selection toggles, multi-select chips, mutable todo lists, key/value settings, in-memory caches, job queues. Use for any in-place collection state driving UI; not for a single immutable value (`ValueNotifier`).

  • 3 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added October 4, 2026
developmentreact

Security analysis

A100/100

Scanned December 2, 2026

npx -y skills add esenmx/collection_notifiers --skill collection-notifiers-usage --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Collection Notifiers Usage?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Collection Notifiers Usage
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/esenmx-collection-notifiers-usage/badge)](https://www.skillsdirectory.com/skills/esenmx-collection-notifiers-usage)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: collection-notifiers-usage
description: 'Wire reactive List/Set/Map/Queue state in Flutter via `package:collection_notifiers` — selection toggles, multi-select chips, mutable todo lists, key/value settings, in-memory caches, job queues. Use for any in-place collection state driving UI; not for a single immutable value (`ValueNotifier`).'
license: MIT
metadata: {version: "1"}
---

# collection-notifiers-usage

|Need|Hook|Ops|
|-|-|-|
|Ordered, indexable, reorderable|`useListNotifier<E>([initial])`|`add`, `assignAll`, `move`, `removeAt`|
|Unique elements, selection toggles|`useSetNotifier<E>([initial])`|`invert(x)`, `add`, `remove`|
|Key -> value lookup|`useMapNotifier<K, V>([initial])`|`m[k] = v`, `remove(k)`|
|FIFO/LIFO head-or-tail mutation|`useQueueNotifier<E>([initial])`|`addLast`, `removeFirst`|

Each hook creates the notifier, disposes on unmount, and rebuilds the host on real changes.

```dart
class const FilterChips({required final List<String> tags, super.key})
    extends HookWidget {
  @override
  Widget build(BuildContext context) {
    final selected = useSetNotifier<String>();
    return Wrap(
      children: [
        for (final tag in tags)
          FilterChip(
            label: Text(tag),
            selected: selected.contains(tag),
            onSelected: (_) => selected.invert(tag),
          ),
      ],
    );
  }
}
```

## Hard rules

- **Mutate, never reassign**: `notifier.assignAll([...])` (1 notification), never `notifier = ListNotifier(...)`. Reorder with `ReorderableListView(onReorderItem: list.move)`.
- **Coalesce with `batch(() { ... })`**: body must be sync; an `async` closure throws `ArgumentError` up front. A `void` arrow forwarding `batch(() => load())` runs until first `await` (notifies once), then throws `ArgumentError`, and later writes notify individually.
- **Disposal**: a hook disposes its notifier on unmount — never dispose it yourself. A notifier you construct is yours to dispose (`State.dispose`, `ref.onDispose`). After `dispose()`, mutators, `batch`, `notifyListeners`, `addListener`, and a second `dispose()` throw `StateError` in every build mode.
- **Never dispose from a listener**: `dispose()` during a notification throws `StateError` and leaves the notifier alive; from a listener it reaches `FlutterError.onError`, not the mutation's caller. Defer the call until the notification ends.
- **`initial` consumed once**: pass hook `keys` (`useListNotifier(initial, [dep])`) or change widget `key` to reset.
- **Backing copy**: `MapNotifier`/`SetNotifier` copy their base like `Map.of`/`Set.of` into a `LinkedHashMap`/`LinkedHashSet` (insertion order, `==` equality) — a `SplayTreeMap`'s order or an identity set's equality is lost.
- **Compose, don't subclass**: notifiers are `final` (hold in a field; use real notifiers in tests).
- **Equality**: `==`/`hashCode` gate notifications (use `freezed`/`equatable` on custom elements); call public `notifyListeners()` after in-place element mutation.
- **Skip for**: single immutable value (`ValueNotifier`), persisted/undoable state (`drift`), cross-isolate state (`Isolate`+`SendPort`).

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.