您可以覆盖上的默认后退箭头
AppBar,然后指定在
Navigator.pop调用时要返回的值以触发状态更改:
伪代码
因此您需要在
onPressed导航按钮的回调中包含类似的内容
onPressed: ()async{ var nav = await Navigator.of(context).push(newRoute); if(nav==true||nav==null){ //change the state } },在你的newRoute中,你应该有这样的东西
new AppBar( leading: new IconButton( icon: new Icon(Icons.arrow_back), onPressed: (){Navigator.pop(context,true)} ),我正在检查这两个值,
null或者
true是因为当用户在android屏幕上(屏幕底部的一个)点击BackButton时返回了空值。我还相信,Flutter中的默认BackButton也会返回null,因此您实际上不需要覆盖该
leading属性,但是我没有自己检查一下,因此可能值得检查。



