$ref<U> function
- @Deprecated('Use KaeruWidget instead. This will be removed in a future version.')
- U value
Creates a reactive Ref with the given initial value
. This can be
used to store and notify changes to a mutable value over the lifetime
of the widget.
The Ref instance is automatically disposed when the widget is disposed.
Note: This is part of the deprecated defineWidget
API.
Example:
final count = ref(0);
void increment() {
count.value++;
}
See also:
- Ref, which is a reactive reference that notifies listeners of changes.
- Computed, which is a lazy-evaluated value that automatically updates whenever its dependencies change.
- AsyncComputed, which is a lazy-evaluated value that automatically updates whenever its dependencies change, and can be used with async functions.
- watch, which allows you to listen to changes to a list of values.
- watchEffect, which allows you to listen to changes to a function.
Implementation
@Deprecated('Use KaeruWidget instead. This will be removed in a future version.')
Ref<U> $ref<U>(U value) => autoContextDispose(Ref(value));