BookmarkToggle class
Toggle helper. Optimistically flips local state, calls the datasource, and on failure re-fetches the canonical truth.
Consumers should ref.read(bookmarkToggleProvider.notifier).toggle(...)
then await ref.read(bookmarkToggleProvider.future) if they need
confirmation. The notifier itself does not expose mutation state —
keep widget feedback subtle (the toggled icon flip is the feedback).
Constructors
Properties
-
future
→ Future<
void> -
Obtains a Future that resolves with the first
statevalue that is not AsyncLoading.no setterinherited - hashCode → int
-
The hash code for this object.
no setterinherited
-
ref
→ AutoDisposeAsyncNotifierProviderRef<
void> -
The Ref from the provider associated with this AsyncNotifier.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
state
↔ AsyncValue<
void> -
The value currently exposed by this AsyncNotifier.
getter/setter pairinherited
Methods
-
build(
) → Future< void> -
Initialize an AsyncNotifier.
override
-
listenSelf(
void listener(AsyncValue< void> ? previous, AsyncValue<void> next), {void onError(Object error, StackTrace stackTrace)?}) → void -
Listens to changes on the value exposed by this provider.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toggle(
{required BookmarkKind kind, required String targetId}) → Future< void> -
Toggle the bookmark for
targetIdof the givenkind. After the write succeeds, invalidates bookmarksProvider and the matching isBookmarkedProvider so dependent UI refreshes. -
toString(
) → String -
A string representation of this object.
inherited
-
update(
FutureOr< void> cb(void), {FutureOr<void> onError(Object err, StackTrace stackTrace)?}) → Future<void> -
A function to update
statefrom its previous value, while abstracting loading/error cases forstate.inherited -
updateShouldNotify(
AsyncValue< void> previous, AsyncValue<void> next) → bool -
A method invoked when the state exposed by this AsyncNotifier changes.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited