Looking up a deactivated widget's ancestor is unsafe. flutter

发布者: 粮油菜大市场 发布时间: 2021.11.23 01:08:31

Looking up a deactivated widget's ancestor is unsafe.

_model.saveMerchantProfile(_formData).then((_) {
          Navigator.of(context).pop();
          if (_model.errorMsg != null) {
            showClzDialog(
                context, _model.errorMsg!,
                onPressFuction: () {
              Navigator.of(context).pop();
            });
          }
      });
 
究其原因,大概是Navigator.of(context).pop();把这个页面的context给销毁了,下面的dialog就找不到context了,改成下面的情况就好了
 
model.saveMerchantProfile(_formData).then((_) {
          showClzDialog(context, _model.errorMsg ?? '保存成功', onPressFuction: () {
            Navigator.of(context).pop();
          });
 });

 

评论
登陆评论

没有评论