storage property
TourStorage
get
storage
Where Hint.showOnce keys are remembered.
Defaults to an InMemoryTourStorage, so a "seen it" hint comes back on
the next launch until you point this at real persistence — once, at
startup. With shared_preferences, in full:
Future<void> main() async {
// Both lines: getInstance is async, and awaiting anything before
// runApp needs the binding to exist first.
WidgetsFlutterBinding.ensureInitialized();
final SharedPreferences prefs = await SharedPreferences.getInstance();
HintRegistry.instance.storage = CallbackTourStorage(
isCompleted: (String key) async =>
prefs.getBool('hint_kit.$key') ?? false,
setCompleted: (String key, bool seen) async => seen
? prefs.setBool('hint_kit.$key', true)
: prefs.remove('hint_kit.$key'),
// Both or neither: this pair is what `start(resume: true)` reads.
lastIndex: (String tour) async => prefs.getInt('hint_kit.$tour.step'),
saveIndex: (String tour, int? index) async => index == null
? prefs.remove('hint_kit.$tour.step')
: prefs.setInt('hint_kit.$tour.step', index),
);
runApp(const MyApp());
}
Tours are remembered separately, in the TourStorage a TourController or TourScope was given. Handing both the same instance is the usual answer — hint_kit says so in debug when only one of the two is set. Keys then share one space: a hint's key is whatever string it was given and a tour's is its name, so keep the two distinct.
Implementation
TourStorage get storage => _storage;
set
storage
(TourStorage value)
Implementation
set storage(TourStorage value) {
_storage = value;
_storageWasSet = true;
}