简体   繁体   English

如何在 flutter 的对话框外点击它时收听?

[英]How to listen to when it is tapped outside a dialog in flutter?

Just as the title says.正如标题所说。 I already set barrierDismissible to false when calling showDialog so that the Dialog is not dismissed when tapping outside of it.在调用 showDialog 时,我已经将barrierDismissible设置为 false,以便在点击它之外时不会关闭 Dialog。 I tried wrapping the Dialog in a GestureDetector and listening to onTap but this only listens to when the dialog is tapped and not outside of it.我尝试将 Dialog 包装在 GestureDetector 中并收听 onTap 但这仅在点击对话框时才收听,而不是在它之外。

You can use await-then您可以使用 await-then

 await showDialog(
       //Your Dialog Code
).then((val){
//here to run on dismiss codes 
    Navigator.pop(_context);
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM