hydrated_state_notifier_hive 1.0.0 hydrated_state_notifier_hive: ^1.0.0 copied to clipboard
An implementation of HydratedStorage from hydrated_state_notifier library which automatically persists and restores states built on top of hive.
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,
);
}