20 lines
539 B
Dart
20 lines
539 B
Dart
import 'package:demo_hive/domain/entity/reminder.dart';
|
|
import 'package:hive/hive.dart';
|
|
import 'package:path_provider/path_provider.dart' as path_provider;
|
|
|
|
class LocalDBInit{
|
|
Box<ReminderEntity> unitBox;
|
|
|
|
Future<void>init() async {
|
|
final appDocumentDirectory =
|
|
await path_provider.getApplicationDocumentsDirectory();
|
|
Hive.init(appDocumentDirectory.path);
|
|
Hive.registerAdapter(ReminderEntityAdapter());
|
|
unitBox = await Hive.openBox("reminder");
|
|
}
|
|
|
|
void dispose(){
|
|
unitBox.compact();
|
|
Hive.close();
|
|
}
|
|
} |