setup library

Setup Widget - A composition-based API for Flutter widgets.

This library provides SetupWidget, a widget system similar to Vue's Composition API, where the setup function executes only once when the widget is created. It includes hooks for reactive state management and lifecycle callbacks.

Classes

HookUtils
Utility functions for SetupWidget hooks and lifecycle management.
JoltSetupContext<T extends SetupWidget<T>>
JoltSignalHook<T extends Disposable>
MemoizedSetupHook<T>
PropsReadonlyNode<T extends SetupWidget<T>>
SetupBuildContext<T extends SetupWidget<T>>
Extension methods for SetupWidget.
SetupBuilder
A convenience widget that uses a builder function for setup.
SetupHook<T>
SetupWidget<T extends SetupWidget<T>>
A widget that uses a composition-based API similar to Vue's Composition API.
SetupWidgetElement<T extends SetupWidget<T>>

Properties

onActivated → void Function(void callback())
Registers a callback to be called when the widget is activated.
final
onChangedDependencies → void Function(void callback())
Registers a callback to be called when widget dependencies change.
final
onDeactivated → void Function(void callback())
Registers a callback to be called when the widget is deactivated.
final
onMounted → void Function(void callback())
Registers a callback to be called when the widget is mounted.
final
onUnmounted → void Function(void callback())
Registers a callback to be called when the widget is unmounted.
final
onUpdated → void Function(void callback())
Registers a callback to be called when the widget is updated.
final
useContext BuildContext Function()
Gets the current BuildContext from the SetupWidget.
final
useSetupContext JoltSetupContext<SetupWidget> Function()
Gets the current JoltSetupContext.
final

Functions

useComputed<T>(T getter(), {JoltDebugFn? onDebug}) Computed<T>
Creates a computed value hook.
useConvertComputed<T, U>(Signal<U> source, T decode(U value), U encode(T value), {JoltDebugFn? onDebug}) ConvertComputed<T, U>
Creates a stream hook from a reactive node. Creates a type-converting computed signal hook.
useHook<T>(SetupHook<T> hook) → T
Creates a hook that persists across rebuilds and hot reloads.
useIterableSignal<T>(Iterable<T> getter(), {JoltDebugFn? onDebug}) IterableSignal<T>
Creates a reactive iterable signal hook.
useJoltEffect(void effect(), {bool immediately = true, JoltDebugFn? onDebug}) Effect
Creates an effect hook.
useJoltEffectScope({bool? detach, JoltDebugFn? onDebug}) EffectScope
Creates an effect scope hook.
useJoltWatcher<T>(SourcesFn<T> sourcesFn, WatcherFn<T> fn, {WhenFn<T>? when, bool immediately = false, JoltDebugFn? onDebug}) Watcher
Creates a watcher hook.
useListSignal<T>(List<T>? value, {JoltDebugFn? onDebug}) ListSignal<T>
Creates a reactive list signal hook.
useMapSignal<K, V>(Map<K, V>? value, {JoltDebugFn? onDebug}) MapSignal<K, V>
Creates a reactive map signal hook.
useMemoized<T>(T creator()) → T
usePersistSignal<T>(T initialValue(), FutureOr<T> read(), FutureOr<void> write(T value), {bool lazy = false, Duration writeDelay = Duration.zero, JoltDebugFn? onDebug}) PersistSignal<T>
Creates a persistent signal hook.
useSetSignal<T>(Set<T>? value, {JoltDebugFn? onDebug}) SetSignal<T>
Creates a reactive set signal hook.
useSignal<T>(T value, {JoltDebugFn? onDebug}) Signal<T>
Creates a reactive signal hook.
useWritableComputed<T>(T getter(), void setter(T), {JoltDebugFn? onDebug}) WritableComputed<T>
Creates a writable computed value hook.

Typedefs

SetupFunction<T> = Widget Function()
A function type that builds a widget from a BuildContext.
SetupFunctionBuilder<T extends SetupWidget<T>> = SetupFunction<T> Function(SetupBuildContext<T> context)
A function type that creates a setup function from a BuildContext.