StateProvider<T> class

A StateProvider is a custom implementation of a NotifierProvider that implements a default notifier with a setState method.

This is handy for simple use cases where you don't need any business logic.

Usage: final myProvider = StateProvider((ref) => 10); // define ref.watch(myProvider); // read ref.notifier(myProvider).setState((old) => old + 1); // write

Constructors

StateProvider.new(T _builder(Ref ref), {String? debugLabel})

Properties

customDebugLabel String?
finalinherited
debugLabel String
A label to be used in debug messages and by the RiverpieTracingPage.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
provider → BaseProvider<StateNotifier<T>, T>
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

compareIdentity(LabeledReference other) bool
Compares the identity of two LabeledReferences.
inherited
getSelectedState(StateNotifier<T> notifier, T state) → T
The default behavior to return the whole state when using ref.watch(provider).
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
overrideWithInitialState(T builder(Ref ref)) ProviderOverride<BaseNotifier, dynamic>
select<R>(R selector(T state)) → SelectedWatchable<StateNotifier<T>, T, R>
Used for ref.watch(provider.select(...)). Select a part of the state.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited