hydrated_state_notifier 1.0.0 hydrated_state_notifier: ^1.0.0 copied to clipboard
An extension to the state_notifier library which automatically persists and restores state_notifier states.
import 'dart:io';
import 'package:hydrated_state_notifier/hydrated_state_notifier.dart';
import 'package:hydrated_state_notifier_hive/hydrated_state_notifier_hive.dart';
import 'package:path/path.dart' as path;
int calculate() {
return 6 * 7;
}
const kIsWeb = identical(0, 0.0);
Future<void> setupStorage() async {
HydratedStorage.storage = await HiveHydratedStorage.build(
storageDirectoryPath: kIsWeb
? ''
: (await Directory(path.join(Directory.current.path, '.cache'))
.create())
.path,
);
}