I have a class where I am doing the graphql setup and the hive box setup. Here is the class -
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');
}
}
Now I initialize this class in the Flutter main method -
Future main() async {
GraphQLConfiguration graphql = new GraphQLConfiguration();
}
When I run this code I get this error message -
Error - Unhandled Exception: HiveError: Box not found. Did you forget to call Hive.openBox()?
I followed this post as well Box not found. Did you forget to call Hive.openBox()?, didn't help.