The app is open then After clicking notification main
gets called again and then getting store
object as null but still getting this error when await openStore()
is called
Unhandled Exception: Bad state: failed to create store: 10001 Cannot open store: another store is still open using the same path
static Future<Store> getStore() async{
if(store != null) {
print("StoreIsNotNull");
return store!;
}else{
print("StoreIsNull");
store = await openStore();
return store!;
}
}
So when notification is clicked then store object is getting as null.
To avoid reopen store while it still already open, just use
Completer
:Then, if you want to get
Person
box from store :So when
initStore
is not complete, thegetStore
will wait and would not return any store instance.