dartfier library
Fine-grained reactivity for Flutter, built entirely on ChangeNotifier.
A Signal holds a value, a Computed derives one, an Effect runs a side
effect and an Observer rebuilds a widget. Reading .value inside a
tracked scope — an Observer builder, a Computed function or an
Effect body — subscribes the reader to that value, so dependencies are
discovered on every run instead of declared up front.
final Signal<int> count = Signal(0);
final Computed<int> doubled = Computed(() => count.value * 2);
count.value = 5;
print(doubled.value); // 10
A write settles in two phases: it first marks the reachable graph stale, waking nobody, and only then does each stale node recompute and notify — and only if its value actually changed. Reads are therefore always consistent, even in a diamond, and a derivation that lands on an equal value stops the cascade there.
Every reactive value is a ChangeNotifier implementing ValueListenable,
so ValueListenableBuilder, Listenable.merge and any Flutter API taking
a Listenable work without an adapter.
See also:
- Signal, the writable reactive value.
- Computed, a lazy value derived from other reactive values.
- ReadonlySignal, the read-only supertype of both.
- Effect, a side effect that reruns when what it read changes.
- Watch, a side effect on a tracked expression, skipping the first run.
- Observer, the widget that rebuilds on the values its builder reads.
- AsyncSignal, which brings asynchronous work into the graph.
- batch, which groups several writes into a single notification.
Classes
-
AsyncData<
T> Async - Operation completed with value.
-
AsyncError<
T> Async - Operation failed with error, optionally carrying the previous data.
-
AsyncIdle<
T> Async - No operation started yet.
-
AsyncLoading<
T> Async - Operation in flight, optionally carrying the previous data.
-
AsyncSignal<
T> Async - A Signal holding the AsyncValue of an asynchronous operation.
-
AsyncValue<
T> Async - The state of an asynchronous operation exposed as a synchronous value.
-
Computed<
T> Core - A derived reactive value with automatic dependency tracking.
- Effect Utilities
- A reactive side effect with automatic dependency tracking.
- Observer
- A widget that rebuilds when any reactive value read in its builder changes.
-
ReadonlySignal<
T> Core - A read-only view of a reactive value.
-
Signal<
T> Core - A reactive value built on ChangeNotifier.
-
Watch<
T> Utilities - A side effect on an auto-tracked expression, skipping the first run.
Extensions
-
ReadonlySignalSubscriptions
on ReadonlySignal<
T> Utilities - Side-effect subscriptions on any ReadonlySignal.
Functions
Typedefs
- EffectCleanup = void Function() Utilities
- A cleanup callback registered by an Effect run.