17 lines
437 B
Dart
17 lines
437 B
Dart
import 'package:hive_flutter/hive_flutter.dart';
|
|
import 'package:trans_lark/entity/history_model.dart';
|
|
|
|
const historyBox = 'historyBox';
|
|
|
|
Future initHive() async {
|
|
// 初始化
|
|
await Hive.initFlutter();
|
|
// 注册类型适配器
|
|
Hive.registerAdapter(HistoryEntityAdapter());
|
|
// 打开盒子
|
|
await Hive.openBox<HistoryEntity>(historyBox);
|
|
}
|
|
|
|
Box<HistoryEntity> getHistoryBox() {
|
|
return Hive.box<HistoryEntity>(historyBox);
|
|
} |