【发布时间】:2021-09-02 18:28:45
【问题描述】:
我有一堂课,我正在做 graphql 设置和蜂巢箱设置。这是课程-
class GraphQLConfiguration {
ValueNotifier<GraphQLClient> client = new ValueNotifier<GraphQLClient>(
GraphQLClient(
cache:
GraphQLCache(store: HiveStore(Hive.box(HiveStore.defaultBoxName))),
link: HttpLink('http://localhost:4000/graphql/',),
),
);
GraphQLConfiguration() {
initializeHive();
}
void initializeHive() async {
await initHiveForFlutter(); // or await initHiveForFlutter();
await Hive.openBox('bolBox');
}
}
现在我在 Flutter 的 main 方法中初始化这个类 -
Future main() async {
GraphQLConfiguration graphql = new GraphQLConfiguration();
}
当我运行此代码时,我收到此错误消息 -
错误 - 未处理的异常:HiveError:找不到框。您是否忘记调用 Hive.openBox()?
我也关注了这个帖子Box not found. Did you forget to call Hive.openBox()?,没有帮助。
【问题讨论】:
标签: flutter flutter-hive