flutter appbar的自动返回按钮 | 您所在的位置:网站首页 › flutter自定义导航栏 › flutter appbar的自动返回按钮 |
appbar里会自动给出返回按钮,但之前也有没有返回按钮的情况,所以还自己写了一个返回按钮 leading: new IconButton( tooltip: '返回上一页', icon: const Icon(Icons.arrow_back), onPressed: () { Navigator.of(context).pop(); //_nextPage(-1); }, ),这是我当时的返回按钮,嗯~很草率的行为 后来发现是我当时把开始路由直接放在这了,没有上一层,故没有返回按钮 appBar:AppBar( //leading: null, /** * 如果没有leading,automaticallyImplyLeading为true,就会默认返回箭头 * 如果 没有leading 且为false,空间留给title * 如果有leading,这个参数就无效了 */ automaticallyImplyLeading : true, title: Text('123'), actions: [ IconButton( icon: Icon(Icons.ac_unit), onPressed: (){ }, ),] ),其实在appbar中还有automaticallyImplyLeading ,可以进行尝试,如果真没有,不妨restart一下,吃过多次没重启的坑,比如刚创建了一个新路由,不重启会报错,找不到该路由 |
CopyRight 2018-2019 实验室设备网 版权所有 |