CallbackTourStorage class Tours
A TourStorage made of two closures, for when writing a class is more ceremony than the job deserves.
This is the shortest path from the in-memory default to real persistence: no subclass, no dependency, and it works with any key-value store the app already has.
TourScope(
storage: CallbackTourStorage(
isCompleted: (String tour) async => prefs.getBool('tour.$tour') ?? false,
setCompleted: (String tour, bool done) async =>
done ? prefs.setBool('tour.$tour', true) : prefs.remove('tour.$tour'),
),
child: const MyApp(),
)
One setter covers both writes: markCompleted calls it with true and
reset with false, so the two can never disagree about where the flag
lives.
- Implemented types
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
isCompleted(
String tour) → Future< bool> -
Whether
tourhas been finished before.override -
lastIndex(
String tour) → Future< int?> -
The step
tourhad reached when the app last stopped, if it was recorded.override -
markCompleted(
String tour) → Future< void> -
Records
touras finished.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reset(
String tour) → Future< void> -
Forgets that
tourwas finished, so it can run again.override -
saveIndex(
String tour, int? index) → Future< void> -
Records that
touris on stepindex, or forgets the position whenindexis null.override -
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited