找到另一个可能的答案:’WillPopScope’可以帮助检测后退按钮是否被按下.
将在’showDialog’中使用的小部件,在其构建函数中,小部件可以包含在’return new WillPopScope(child:______,onWillPop:_______)中;代码可以在’onWillPop’函数中运行.这可以更新下面的主页.
await showDialog( //Your Dialog Code ).then((val){ Navigator.pop(_context); });