【发布时间】:2021-08-27 08:23:23
【问题描述】:
我有一个带有 Hive 数据库的颤振应用程序。我在底部导航栏中有两个页面。当我在第一个时,一切正常,我所有的 CRUD 操作。但是当我转到第二页并试图返回时,框突然关闭,因为我收到此错误:
Box not found. Did you forget to call Hive.openBox()?
我在 main 方法中打开我的蜂箱:
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Hive.initFlutter();
Hive.registerAdapter(MeasurmentAdapter());
await Hive.openBox<Measurment>('measurments');
runApp(MyApp());
}
如果没有这个,我该如何解决这个问题并浏览我的页面?
【问题讨论】:
标签: flutter android-studio dart flutter-hive