flutter_value_notifier library

Classes

DependencyProvider<T>
Takes a Create function that is responsible for creating the dependency and a child which will have access to the dependency via DependencyProvider.of(context). It is used as a dependency injection (DI) widget so that a single instance of a dependency can be provided to multiple widgets within a subtree.
MultiDependencyProvider
Merges multiple DependencyProvider widgets into one widget tree.
MultiValueNotifierListener
Merges multiple ValueNotifierListener widgets into one widget tree.
MultiValueNotifierProvider
Merges multiple ValueNotifierProvider widgets into one widget tree.
ValueNotifierBuilder<VN extends ValueNotifier<V>, V>
ValueNotifierBuilder handles building a widget in response to new values. ValueNotifierBuilder is analogous to ValueListenableBuilder but has simplified API to reduce the amount of boilerplate code needed as well as notifier-specific performance improvements. Please refer to ValueNotifierListener if you want to "do" anything in response to value changes such as navigation, showing a dialog, etc...
ValueNotifierBuilderBase<VN extends ValueNotifier<V>, V>
Base class for widgets that build themselves based on interaction with a specified notifier.
ValueNotifierConsumer<VN extends ValueNotifier<V>, V>
ValueNotifierConsumer exposes a builder and listener in order react to new values. ValueNotifierConsumer is analogous to a nested ValueNotifierListener and ValueNotifierBuilder but reduces the amount of boilerplate needed. ValueNotifierConsumer should only be used when it is necessary to both rebuild UI and execute other reactions to value changes in the notifier.
ValueNotifierListener<VN extends ValueNotifier<V>, V>
Takes a ValueNotifierWidgetListener and an optional notifier and invokes the listener in response to value changes in the notifier. It should be used for functionality that needs to occur only in response to a value change such as navigation, showing a SnackBar, showing a Dialog, etc... The listener is guaranteed to only be called once for each value change unlike the builder in ValueNotifierBuilder.
ValueNotifierListenerBase<VN extends ValueNotifier<V>, V>
Base class for widgets that listen to value changes in a specified notifier.
ValueNotifierProvider<T extends ValueNotifier<Object?>>
Takes a Create function that is responsible for creating the ValueNotifier and a child which will have access to the instance via ValueNotifierProvider.of(context). It is used as a dependency injection (DI) widget so that a single instance of a ValueNotifier can be provided to multiple widgets within a subtree.
ValueNotifierSelector<VN extends ValueNotifier<V>, V, T>
ValueNotifierSelector is analogous to ValueNotifierBuilder but allows developers to filter updates by selecting a new value based on the notifier value. Unnecessary builds are prevented if the selected value does not change.

Extensions

ReadContext on BuildContext
Exposes the read method.
SelectContext on BuildContext
Adds a select method on BuildContext.
WatchContext on BuildContext
Exposes the watch method.

Typedefs

ValueNotifierBuilderCondition<V> = bool Function(V previous, V current)
Signature for the buildWhen function which takes the previous value and the current value and is responsible for returning a bool which determines whether to rebuild ValueNotifierBuilder with the current value.
ValueNotifierListenerCondition<V> = bool Function(V previous, V current)
Signature for the listenWhen function which takes the previous value and the current value and is responsible for returning a bool which determines whether or not to call ValueNotifierWidgetListener of ValueNotifierListener with the current value.
ValueNotifierWidgetBuilder<V> = Widget Function(BuildContext context, V value)
Signature for the builder function which takes the BuildContext and value and is responsible for returning a widget which is to be rendered. This is analogous to the builder function in ValueListenableBuilder.
ValueNotifierWidgetListener<V> = void Function(BuildContext context, V value)
Signature for the listener function which takes the BuildContext along with the value and is responsible for executing in response to value changes.
ValueNotifierWidgetSelector<V, T> = T Function(V value)
Signature for the selector function which is responsible for returning a selected value, T, based on value.

Exceptions / Errors

ProviderNotFoundException
The error that will be thrown if Provider.of fails to find a Provider as an ancestor of the BuildContext used.