flutter - Streambuilder没有在颤动的对话框内被调用
问题描述
我正在使用下面的代码。我单击某个按钮,如果我的 OTP 匹配下面的方法被调用。在那种方法中,我正在调用 bloc。我正在使用的小部件是 Statefulwidget。
void matchOtp() {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text(ALERT_TITLE),
content: Text(OtpMatchSuccess),
actions: <Widget>[
IconButton(
icon: Icon(Icons.check),
onPressed: () {
if(OtpMatchSuccess == ALERT_OTP_MATCHED){
bloc.calledmethodinBloc(); // this method get called properly
StreamBuilder(
stream: bloc.usertype,
builder: (context, AsyncSnapshot<
ResponseModel> snapshot) {
print("INSIDE"); // My code does not go here.
return Center(child: CircularProgressIndicator());
}
);
print("OUTSIDE");// My code moves outside the streambuilder. Is there any reason for that?
}else{
Navigator.of(context, rootNavigator: true).pop('dialog');
}
})
],
);
});
}
解决方案
推荐阅读
- reactjs - React - 有条件的父组件
- python-3.x - TheGuardian API - 脚本崩溃
- postgresql - 创建并写入数据库 JDBC PySpark
- r - 如何按顺序按组对值求和
- git - 我怎样才能更新 git?
- java - 如何从 WebView 中提取 html 代码并将其放入 TextView?
- typescript - TypeScript:函数类型派生,为什么类型d为真?
- javascript - undefined 不是对象(评估 '_react.React.Component')
- python - 为 np.array 分配较大的值
- ubuntu - 协议错误:尝试将文件夹/文件从远程服务器传输到本地时,mtime.sec 不存在