hive property
String
hive
getter/setter pair
Implementation
String hive = '''
import 'package:hive_flutter/hive_flutter.dart';
class MyHive {
// prevent making instance
MyHive._();
// box name its like table name
static const String _userBoxName = 'user';
// store current user as (key => value)
static const String _currentUserKey = 'local_user';
/// initialize local db (HIVE)
/// pass testPath only if you are testing hive
static Future<void> init(
{Function(HiveInterface)? registerAdapters, String? testPath}) async {
if (testPath != null) {
Hive.init(testPath);
} else {
await Hive.initFlutter();
}
await registerAdapters?.call(Hive);
}
// setup your methods for local db here
}
''';