setup
library
Classes
-
Derived<T>
-
Represents a derived value that depends on other reactive references.
-
Effect<T>
-
Represents a reactive effect that automatically tracks and responds to changes in reactive references.
-
EffectRunner<T>
-
Represents a runner for reactive effects.
-
Observer
-
A widget that rebuilds whenever its builder function returns a different value.
-
Ref<T>
-
Represents a reactive reference to a value of type T.
-
Scope
-
Represents a scope for managing reactive effects and computations.
-
SetupElement
-
An Element that represents the runtime contract of a SetupWidget.
-
SetupWidget
-
A base widget class that supports reactive setup and lifecycle hooks.
-
WidgetRef<T extends SetupWidget>
-
A reference to a SetupWidget and its associated BuildContext.
Extension Types
-
WatchHandle
-
A handle for controlling a watch operation.
Extensions
-
DerivedUtils
on Derived<T> Function<T>(T _())
-
Utility extension for creating different types of derived references.
-
RefObserverUtils
on Ref<T>
-
Extension methods for creating observers from Ref objects.
Functions
-
batch(void runner())
→ void
-
Executes a batch operation.
-
createScope([bool detached = false])
→ Scope
-
Creates an effects scope.
-
customRef<T>(({T Function() get, void Function(T) set}) factory(void track(), void trigger()))
→ Ref<T>
-
Creates a custom Ref with user-defined getter and setter behavior.
-
derived<T>(T getter())
→ Derived<T>
-
Creates a new Derived reference.
-
effect<T>(T runner(), {void scheduler()?, void onStop()?})
→ EffectRunner<T>
-
Creates and runs an effect.
-
enableTracking()
→ void
-
Reenables effect tracking.
-
getCurrentScope()
→ Scope?
-
Returns the current active effects scope if there is one.
-
inferReturnType<F extends Function>(F fn)
→ F
-
Enables precise type inference for function return types.
-
inject<T>(Object key)
→ T?
-
Injects a value of type T associated with the given key.
-
isReactive<T>(T value)
→ bool
-
Checks if a value is reactive object.
-
isRef(dynamic value)
→ bool
-
Checks if a value is a Ref instance.
-
nextTick([VoidCallback? callback])
→ Future<void>
-
Schedules a callback to be executed in the next frame.
-
obs<T>(Ref<T> ref, Widget builder(T value), {Key? key})
→ SetupWidget
-
Creates an Observer widget for the given
ref.
-
onActivated(void hook())
→ void
-
Called when a cached component is activated
-
onBeforeMount(void hook())
→ void
-
Called before the component is mounted to the DOM
-
onBeforeUnmount(void hook())
→ void
-
Called right before the component is unmounted from the DOM
-
onBeforeUpdate(void hook())
→ void
-
Called before the component is updated
-
onDeactivated(void hook())
→ void
-
Called when a cached component is deactivated
-
onEffectCleanup(void cleanup(), [dynamic failSilently = false])
→ void
-
Registers a cleanup function for the current active effect.
-
onMounted(void hook())
→ void
-
Called after the component is mounted to the DOM
-
onScopeDispose(void cleanup(), [bool failSilently = false])
→ void
-
Registers a dispose callback on the current active effects scope.
-
onUnmounted(void hook())
→ void
-
Called after the component is unmounted from the DOM
-
onUpdated(void hook())
→ void
-
Called after the component is updated
-
pauseTracking()
→ void
-
Temporarily pauses tracking.
-
provide<T>(Object key, T value)
→ void
-
Provides a value of type T associated with a key in the current element's scope.
-
reactiveIterable<E>(Iterable<E> iterable)
→ Iterable<E>
-
Creates a reactive iterable from the given
iterable.
-
reactiveList<E>(List<E> list)
→ List<E>
-
Creates a reactive list from the given
list.
-
reactiveMap<K, V>(Map<K, V> map)
→ Map<K, V>
-
Creates a reactive map from the given
map.
-
reactiveSet<E>(Set<E> set)
→ Set<E>
-
Creates a reactive set from the given
set.
-
ref<T>(T value)
→ Ref<T>
-
Creates a value reference.
-
resetTracking()
→ void
-
Resets the tracking state to the previous value.
-
toRaw<T>(T value)
→ T
-
Converts a reactive object to its raw value.
-
triggerRef<T>(Ref<T> ref)
→ void
-
Triggers the update of a Ref instance.
-
unref<R>(dynamic ref)
→ R
-
Unwraps a Ref instance if the given value is a Ref, otherwise returns the value as-is.
-
untracked<T>(T runner())
→ T
-
Executes a function without tracking its dependencies.
-
useContext()
→ BuildContext
-
Returns the current BuildContext from the widget.
-
useWidgetRef<T extends SetupWidget>()
→ WidgetRef<T>
-
Creates a reference to a SetupWidget of type
T.
-
watch<T extends Record>(T compute(), void runner(T value, T? oldValue), {bool immediate = false, bool once = false})
→ WatchHandle
-
Watches a computed value and runs a callback when it changes.