Streambuilder не вызывается внутри диалогового окна во флаттере - PullRequest
0 голосов
/ 28 марта 2020

Я использую код ниже. Я нажимаю какую-то кнопку, и, если мой метод OTP-соответствия ниже вызывается. и в этом методе я вызываю blo c. Виджет, который я использую - 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');
                    }
                  })
            ],
          );
        });
  }
...