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

CallbackTourStorage({required Future<bool> isCompleted(String tour), required Future<void> setCompleted(String tour, bool completed), Future<int?> lastIndex(String tour)?, Future<void> saveIndex(String tour, int? index)?})
Creates a storage backed by isCompleted and setCompleted.
const

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 tour has been finished before.
override
lastIndex(String tour) Future<int?>
The step tour had reached when the app last stopped, if it was recorded.
override
markCompleted(String tour) Future<void>
Records tour as finished.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reset(String tour) Future<void>
Forgets that tour was finished, so it can run again.
override
saveIndex(String tour, int? index) Future<void>
Records that tour is on step index, or forgets the position when index is null.
override
toString() String
A string representation of this object.
override

Operators

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