signals_flutter library

Classes

AsyncData<T>
State for an AsyncState with a value
AsyncError<T>
State for an AsyncState with an error
AsyncLoading<T>
State for an AsyncState with a loading state
AsyncSignal<T>
The signal function creates a new signal. A signal is a container for a value that can change over time. You can read a signal's value or subscribe to value updates by accessing its .value property.
AsyncState<T>
AsyncState is class commonly used with Future/Stream signals to represent the states the signal can be in.
ChangeStackSignal<T>
Change stack signal that can be used to call undo/redo on a value.
Computed<T>
Data is often derived from other pieces of existing data. The computed function lets you combine the values of multiple signals into a new signal that can be reacted to, or even used by additional computeds. When the signals accessed from within a computed callback change, the computed callback is re-executed and its new return value becomes the computed signal's value.
Connect<T, S extends T>
The idea for connect comes from Anguar Signals with RxJS:
DevToolsSignalsObserver
Signals DevTools observer
Effect
The effect function is the last piece that makes everything reactive. When you access a signal inside its callback function, that signal and every dependency of said signal will be activated and subscribed to. In that regard it is very similar to computed(fn). By default all updates are lazy, so nothing will update until you access a signal inside effect.
ElementWatcher
Helper class to track signals and effects with the lifecycle of an element.
FutureSignal<T>
Future signals can be created by extension or method.
IterableSignal<E>
A Signal that holds a Iterable.
ListSignal<E>
A Signal that holds a List.
LoggingSignalsObserver
Logs all signals and computed changes to the console.
MapSignal<K, V>
A Signal that holds a Map.
QueueSignal<T>
A Signal that holds a Queue.
ReadonlySignal<T>
Read only signals can just retrieve a value but not update or cause mutations
SetSignal<E>
A Signal that holds a Set.
Signal<T>
The signal function creates a new signal. A signal is a container for a value that can change over time. You can read a signal's value or subscribe to value updates by accessing its .value property.
SignalContainer<T, Arg, S extends ReadonlySignal<T>>
Signal container used to create signals based on args
SignalListenable
Signal listenable that both Computed and Effect extend
SignalsObserver
You can observe all signal values in the dart application by providing an implementation of SignalsObserver:
SignalValueListenable<T, N extends ValueListenable<T>, S extends ReadonlySignal<T>>
Signal + ValueListenable
SignalValueNotifier<T>
Signal + ValueNotifier
StreamSignal<T>
Stream signals can be created by extension or method.
TickerSignal
Ticker signal used to drive animations and can create animation controllers
TimerSignal
Emit recurring TimerSignalEvent aka AsyncSignal
Watch<T extends Widget>
Watch
WrappedReadonlySignal<T, S extends ReadonlySignal<T>>
Wrap a ReadonlySignal and implement the same API
WrappedSignal<T>
Wrap a Signal and implement the same API

Mixins

SignalsAutoDisposeMixin<T extends StatefulWidget>
Auto dispose any signal/computed/effect created within the state class
SignalsMixin<T extends StatefulWidget>
Signals mixin that will automatically rebuild the widget tree when any of the signals change and dispose of any signals and effects created locally.
ValueSignalMixin<T>
Value Signal mixin (list/map/set)

Extensions

FlutterReadonlySignalUtils on ReadonlySignal<T>
Signal extensions
FlutterSignalUtils on Signal<T>
Mutable signal utils
ReadonlySignalUtils on ReadonlySignal<T>
Signal extensions
SignalFutureUtils on Future<T>
Extension on future to provide helpful methods for signals
SignalIterableUtils on Iterable<T>
Extension on future to provide helpful methods for signals
SignalListUtils on List<T>
Extension on future to provide helpful methods for signals
SignalMapUtils on Map<K, V>
Extension on future to provide helpful methods for signals
SignalObjectUtils on T
Extension on Object to provide helpful methods for signals
SignalOptionalObjectUtils on T?
Extension on nullable Object to provide helpful methods for signals
SignalQueueUtils on Queue<T>
Extension on future to provide helpful methods for signals
SignalsCallbackFunctionUtils on SignalsCallbackFunction<T>
A callback function that can be used to update a signal.
SignalSetUtils on Set<T>
Extension on future to provide helpful methods for signals
SignalStreamUtils on Stream<T>
Extension on stream to provide helpful methods for signals
SignalValueListenableUtils on ValueListenable<T>
Extension on ValueListenable to provide helpful methods for signals
SignalValueNotifierUtils on ValueNotifier<T>
Extension on ValueNotifier to provide helpful methods for signals
TimerSignalDurationUtils on Duration
Expose Duration as a TimerSignal

Properties

allowSignalsCreatedInBuildContext bool
If true it would allow creating signals inside the build method.
getter/setter pair
signalsDevToolsEnabled bool
Check if the signals devtools are enabled
getter/setter pair

Functions

asyncSignal<T>(AsyncState<T> value, {String? debugLabel, bool autoDispose = false}) AsyncSignal<T>
The signal function creates a new signal. A signal is a container for a value that can change over time. You can read a signal's value or subscribe to value updates by accessing its .value property.
batch<T>(BatchCallback<T> fn) → T
The batch function allows you to combine multiple signal writes into one single update that is triggered at the end when the callback completes.
bindComputed<T>(BuildContext context, Computed<T> target, {String? debugLabel}) Computed<T>
Bind an existing computed to a widget.
bindSignal<T, S extends ReadonlySignal<T>>(BuildContext context, S target, {String? debugLabel}) → S
Bind an existing signal to a widget.
changeStack<T>(T value, {String? debugLabel, int? limit, bool autoDispose = false}) ChangeStackSignal<T>
Change stack signal that can be used to call undo/redo on a value.
computed<T>(ComputedCallback<T> compute, {String? debugLabel, bool autoDispose = false}) Computed<T>
Data is often derived from other pieces of existing data. The computed function lets you combine the values of multiple signals into a new signal that can be reacted to, or even used by additional computeds. When the signals accessed from within a computed callback change, the computed callback is re-executed and its new return value becomes the computed signal's value.
computedAsync<T>(Future<T> callback(), {T? initialValue, String? debugLabel, bool autoDispose = false, List<ReadonlySignal> dependencies = const [], bool lazy = true}) FutureSignal<T>
Async Computed is syntax sugar around FutureSignal.
computedFrom<T, A>(List<ReadonlySignal<A>> signals, Future<T> callback(List<A> args), {T? initialValue, String? debugLabel, bool autoDispose = false, bool lazy = true}) FutureSignal<T>
Async Computed is syntax sugar around FutureSignal.
connect<T, S extends T>(Signal<T> signal, [Stream<S>? stream]) Connect<T, S>
The idea for connect comes from Anguar Signals with RxJS:
createComputed<T>(BuildContext context, T compute(), {String? debugLabel, bool autoDispose = true}) Computed<T>
Create and watch a computed signal and rebuild on changes.
createSignal<T>(BuildContext context, T value, {String? debugLabel, bool autoDispose = true}) Signal<T>
Create and watch a signal and rebuild on changes.
disableSignalsDevTools() → void
Disable the devtools
effect(EffectCallback compute, {String? debugLabel, EffectCallback? onDispose}) EffectCleanup
The effect function is the last piece that makes everything reactive. When you access a signal inside its callback function, that signal and every dependency of said signal will be activated and subscribed to. In that regard it is very similar to computed(fn). By default all updates are lazy, so nothing will update until you access a signal inside effect.
futureSignal<T>(Future<T> callback(), {T? initialValue, String? debugLabel, List<ReadonlySignal> dependencies = const [], bool lazy = true, bool autoDispose = false}) FutureSignal<T>
Future signals can be created by extension or method.
iterableSignal<T>(Iterable<T> iterable, {String? debugLabel, bool autoDispose = false}) IterableSignal<T>
Create an IterableSignal from Iterable
lazySignal<T>({String? debugLabel, bool autoDispose = false}) Signal<T>
Lazy signal that can be created with type T that the value will be assigned later.
listenSignal<T>(BuildContext context, ReadonlySignal<T> signal, void callback(), {String? debugLabel}) → void
Used to listen for updates on a signal but not rebuild the nearest element
listSignal<T>(List<T> list, {String? debugLabel, bool autoDispose = false}) ListSignal<T>
Create an ListSignal from List
mapSignal<K, V>(Map<K, V> map, {String? debugLabel, bool autoDispose = false}) MapSignal<K, V>
Create an MapSignal from Map
queueSignal<T>(Queue<T> list, {String? debugLabel, bool autoDispose = false}) QueueSignal<T>
Create an QueueSignal from Queue
readonlySignalContainer<T, Arg>(ReadonlySignal<T> create(Arg), {bool cache = false}) SignalContainer<T, Arg, ReadonlySignal<T>>
Create a signal container used to instance signals based on args
reloadSignalsDevTools() → void
Reload the devtools
setSignal<T>(Set<T> list, {String? debugLabel, bool autoDispose = false}) SetSignal<T>
Create an SetSignal from Set
signal<T>(T value, {String? debugLabel, bool autoDispose = false}) Signal<T>
The signal function creates a new signal. A signal is a container for a value that can change over time. You can read a signal's value or subscribe to value updates by accessing its .value property.
signalContainer<T, Arg>(Signal<T> create(Arg), {bool cache = false}) SignalContainer<T, Arg, Signal<T>>
Create a signal container used to instance signals based on args
signalValueListenable<T>(T val, {String? debugLabel, bool autoDispose = false}) SignalValueListenable<T, ValueListenable<T>, ReadonlySignal<T>>
Signal + ValueListenable
signalValueNotifier<T>(T val, {String? debugLabel, bool autoDispose = false}) SignalValueNotifier<T>
Signal + ValueNotifier
streamSignal<T>(Stream<T> callback(), {T? initialValue, String? debugLabel, List<ReadonlySignal> dependencies = const [], void onDone()?, bool? cancelOnError, bool lazy = true, bool autoDispose = false}) StreamSignal<T>
Stream signals can be created by extension or method.
tickerSignal({Duration? initialDuration, String? debugLabel}) TickerSignal
Ticker signal used to drive animations and can create animation controllers
timerSignal(Duration every, {String debugLabel = 'Timer', bool? cancelOnError, bool autoDispose = false}) TimerSignal
Create a TimerSignal
unlistenSignal<T>(BuildContext context, ReadonlySignal<T> signal, void callback(), {String? debugLabel}) → void
Remove all subscribers for a given signal for watchers
untracked<T>(UntrackedCallback<T> fn) → T
In case when you're receiving a callback that can read some signals, but you don't want to subscribe to them, you can use untracked to prevent any subscriptions from happening.
unwatchSignal<T>(BuildContext context, ReadonlySignal<T> signal) → void
Remove all subscribers for a given signal for watchers
valueListenableToSignal<T>(ValueListenable<T> valueListenable) SignalValueListenable<T, ValueListenable<T>, ReadonlySignal<T>>
SignalValueNotifier
valueNotifierToSignal<T>(ValueNotifier<T> valueNotifier, {String? debugLabel, bool autoDispose = false}) SignalValueNotifier<T>
SignalValueNotifier
valueSignal<T>(T value, {String? debugLabel, bool autoDispose = false}) ValueSignal<T>
Wrapper signal for a reference to an object
watchSignal<T>(BuildContext context, ReadonlySignal<T> signal, {String? debugLabel}) → T
Watch a signal value and rebuild the context of the Element if mounted and mark it as dirty

Typedefs

AsyncDataBuilder<E, T> = E Function(T value)
Value builder for AsyncState
AsyncErrorBuilder<E> = Function
Error builder for AsyncState
AsyncStateBuilder<E> = E Function()
Generic builder for AsyncState
BatchCallback<T> = T Function()
A callback that is executed inside a batch.
ComputedCallback<T> = T Function()
A callback that is executed inside a computed.
EffectCallback = dynamic Function()
Function called when signals in the callback change
EffectCleanup = void Function()
Clean up function to stop subscriptions from updating the callback
SignalChange<T> = ({T previousValue, T value})
Signal change that contains a snapshot of the previous value and next value
SignalsCallbackFunction<T> = dynamic Function(dynamic (T value))
A callback function that can be used to update a signal.
TimerSignalEvent = ({int iteration, int millis})
Time event to react to
UntrackedCallback<T> = T Function()
A callback that is executed inside a computed.
ValueSignal<T> = Signal<T>
Alias for Signal

Exceptions / Errors

EffectCycleDetectionError
Cycle detection usually means you have updated a signal inside an effect and are reading by value.
LazySignalInitializationError
Lazy signal must value value set before it is read
SignalsError
Signal usage error
SignalsReadAfterDisposeError
Error to throw if a signal is read after it is disposed
SignalsWriteAfterDisposeError
Error to throw if a signal is written to after it is disposed