ref/ref library

Classes

ComputedScoped<Result>
ComputeRef
GetScope
A widget that allows setting Substitutions for Get objects.
Hook<Result, Data>
Allows a Widget to create and access its own mutable data without a State.
HookData<Result>
This class makes it easier for a Hook to work with a complex data model.
HookRef
ObjectRef<T>
A class that stores a single value.
ScopedGet<T>
Creates pseudo-Get objects that throw when properties are accessed.
ScopeModel
An InheritedModel used by Ref to store its Overrides and notify dependent widgets.
Substitution<V extends ValueRef>
Causes the static Ref methods to reference a different Get object.

Mixins

DisposeGuard
Mixin for Get objects with a dispose method.
HookElement
An Element that uses a HookWidget as its configuration.

Extension Types

Get
Encapsulates a ValueListenable object with an interface for easy updates and automatic lifecycle management.
GetAsync
Encapsulates an AsyncNotifier.
GetComputed
Encapsulates a Listenable which notifies based on a RefComputer callback.
GetList
Encapsulates a ListNotifier and can be used as a List directly.
GetMap
Encapsulates a MapNotifier and can be used as a Map directly.
GetProxy
Encapsulates any Listenable, using the provided callback to retrieve a value.
GetSet
Encapsulates a SetNotifier and can be used as a Set directly.
GetValue
Encapsulates a ValueNotifier.
GetVsync
Encapsulates an Animation.
GetVsyncDouble
Encapsulates an AnimationController.
GetVsyncValue
Encapsulates a ValueAnimation.
Ref
A namespace for Hook functions that interact with Get objects.

Extensions

GetFromContext on BuildContext
Allows accessing the relevant value from an ancestor GetScope in a reasonably concise manner.
GetHooked on Get<Object?, V>
Allows the hook functions defined in Ref to access a Get object's ValueListenable.
ToggleValue on GetValue<bool>
Toggles a boolean GetValue.
VsyncRef on ComputeRef

Constants

useAnimation → const T Function<T>(ValueListenable<T> valueListenable, {bool watching = true})
Animations are just ValueListenables with an AnimationStatus!

Functions

use<Result, Data>(GetHook<Result, Data> getHook, {required Object? key, required Data data, required String debugLabel}) → Result
Registers a Hook and returns its value.
useAnimationStatus<T>(Animation<Object?> animation, T statusListener(AnimationStatus status)) → T
Calls the statusListener whenever the Animation.status changes.
useContext() BuildContext
Obtains the BuildContext of the building HookWidget.
useEffect(ValueGetter<VoidCallback?> effect, {Object? key}) → void
Invokes the effect callback, and calls it again whenever the key changes.
useListenable<L extends Listenable?>(L listenable, {bool watching = true}) → L
Subscribes to a Listenable and marks the widget as needing build whenever the listener is called.
useMemoized<T>(ValueGetter<T> valueGetter, {Object? key}) → T
Caches the instance of a complex object.
useRef<T>(T initialValue, {Object? key}) ObjectRef<T>
Creates an object containing a property which can be mutated without triggering rebuilds.
useSubstitute<G extends GetAny>(G get, Object replacer, {Object? key}) → G
Creates a Substitution and automatically applies it to the nearest ancestor GetScope.
useValueListenable<T>(ValueListenable<T> valueListenable, {bool watching = true}) → T
Subscribes to a ValueListenable and returns its value.

Typedefs

GetAny = Get<Object?, ValueRef>
A generic type implemented by all Get objects.
GetGetter<V extends ValueRef> = ValueGetter<GetV<V>>
A callback that returns a Get object that wraps the specified ValueListenable.
GetHook<Result, Data> = ValueGetter<Hook<Result, Data>>
Signature for a callback that returns a Hook.
GetT<T> = Get<T, ValueListenable<T>>
Shorthand for specifying a Get object's first type argument.
GetV<V extends ValueRef> = Get<Object?, V>
Shorthand for specifying a Get object's second type argument.
GetVsyncA<A extends Animation<Object?>> = GetVsync<Object?, A>
Shorthand for specifying a GetVsync object's second type argument.
GetVsyncAny = GetVsync<Object?, Animation<Object?>>
A generic type implemented by all GetVsync objects.
GetVsyncT<T> = GetVsync<T, Animation<T>>
Shorthand for specifying a GetVsync object's first type argument.
RefComputer<Result> = Result Function(ComputeRef ref)
SubAny = Substitution<ValueRef>
A generic type that encompasses all Substitution objects.

Exceptions / Errors

GetScopeError
Might as well use a fun little class for the scope errors!