n' t可以弹出当前屏幕获取'!_ debuglocked':不是真的
我正在使用 Bloc 状态管理进行更新状态。我想弹出当前屏幕以聆听Bloc侦听器的状态更改,但显示“!_debuglocked”:在控制台上是不正确的。我尝试了一些类似的问题,例如:
第一尝试:
WidgetsBinding.instance.addPostFrameCallback((_) {
Navigator.pop(context);
});
第二尝试:
Future.delayed(const Duration(milliseconds: 500), () {
Navigator.pop(context);
}
我的bloclistener:
BlocListener<CreateLabelCubit, CreateLabelState>(
listener: (context, state) {
if (state.networkState == NetworkState.success) {
FlushbarHelper.createSuccess(message: 'Create Label Successful!')
.show(context);
//refresh label list
labelListBloc.add(LabelListFetched());
//& pop form create label page
/*WidgetsBinding.instance?.addPostFrameCallback((_) {
Navigator.pop(context);
});*/
Navigator.pop(context);
} else if (state.networkState == NetworkState.failure) {
FlushbarHelper.createError(message: state.toString()).show(context);
}
},
I'm using bloc state management for update state. I want to pop current screen to listen state changes from bloc listener but shows '!_debugLocked': is not true on console. There are some similar question I try there solutions like:
1st attempt:
WidgetsBinding.instance.addPostFrameCallback((_) {
Navigator.pop(context);
});
2nd attempt:
Future.delayed(const Duration(milliseconds: 500), () {
Navigator.pop(context);
}
My BlocListener:
BlocListener<CreateLabelCubit, CreateLabelState>(
listener: (context, state) {
if (state.networkState == NetworkState.success) {
FlushbarHelper.createSuccess(message: 'Create Label Successful!')
.show(context);
//refresh label list
labelListBloc.add(LabelListFetched());
//& pop form create label page
/*WidgetsBinding.instance?.addPostFrameCallback((_) {
Navigator.pop(context);
});*/
Navigator.pop(context);
} else if (state.networkState == NetworkState.failure) {
FlushbarHelper.createError(message: state.toString()).show(context);
}
},
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您还可以这样做:
编辑
您必须使用
上下文
来自build> build
不是来自bloclistener
这样的方法:
您可以在
内部使用Navigator的
pop
方法navigator.pop(_context);
[按照我的示例]You can do this way also :
EDIT
You have to use
context
fromBuild
method not fromBlocListener
like this :
and you can use inside
Navigator's
pop
methodNavigator.pop(_context);
[as per my example]