获取错误为“未经手的异常:不良状态:无法创建商店:10001无法打开商店:另一家商店仍使用相同的路径打开。
该应用是打开的,然后单击通知MAIN
再次调用,然后获取store
对象为null,但是当等待OpenStore()
时仍会遇到此错误。被称为
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!;
}
}
,因此单击通知时,存储对象将作为null获取。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我遇到了同样的问题,试图从背景任务开设商店。该问题是通过使用已经开放的商店或创建新商店(如果尚未打开的)来解决的。
I encountered the same issue trying to open a store from a background task. The issue was resolved by using an already open store or create a new store if not yet opened.
要避免在仍在打开的情况下重新打开商店,只需使用
完成器
:然后,如果您想从商店中获取
Person
box:因此,当
Initstore
时未完成,getstore
将等待,并且不会返回任何商店实例。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.尝试
使用async函数,使用异步函数重做代码,如果您要执行的函数或命令是完成的,它将移至下一步不会关闭自己,对于一个程序来说,这有点沉重,您应该只允许执行它
喜欢: - &gt;打开我 - &gt;一个已完成的打开 - &GT;然后完成
Try this instead
use an async function, redo the code with an async function, if the function or command you wanted to do was done, it would move to next, instead of clicking on the notification that would become null and would stay there and it wouldn't close itself, that's kinda heavy for a program you should only allow executions it would have
like : -> open me -> one done opening closed -> then done
使用对象盒: ^2.0.0
Using objectbox: ^2.0.0