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
- SetupBuilder
- A convenience widget that uses a builder function for setup.
- SetupWidget
- A widget that uses a composition-based API similar to Vue's Composition API.
-
SetupWidgetElement<
T extends SetupWidget>
Extensions
- SetupWidgetExtension on T
- Extension methods for SetupWidget.
Properties
- onChangedDependencies → void Function(void callback())
-
Registers a callback to be called when widget dependencies change.
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
-
useHook
→ T Function<
T>(T hook()) -
Creates a hook that persists across rebuilds and hot reloads.
final
- useSetupContext → JoltSetupContext Function()
-
Gets the current JoltSetupContext.
final
-
useWidgetProps
→ ReadonlyNode<
T> Function<T extends SetupWidget>() -
Returns a reactive reference to the widget instance.
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 type-converting computed signal hook.
-
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.
-
useJoltStream<
T> (ReadonlyNode< T> node, {JoltDebugFn? onDebug}) → Stream<T> - Creates a stream hook from a reactive node.
-
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.
-
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 = WidgetBuilder
- A function type that builds a widget from a BuildContext.
- SetupFunctionBuilder = SetupFunction Function(BuildContext context)
- A function type that creates a setup function from a BuildContext.