【问题标题】:How to change the function of the back button in the flutter app bar?如何更改flutter应用栏后退按钮的功能?
【发布时间】:2022-10-21 20:32:26
【问题描述】:
如何更改应用栏中后退按钮的功能?所以我想在你点击后退按钮时转到主页我怎样才能做到这一点?
appBar: AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
leading: const BackButton(
color: Color(0xFFFD879A),
),
),
【问题讨论】:
标签:
flutter
dart
flutter-layout
appbar
【解决方案1】:
将onPressed 添加到您的leading:
leading: BackButton(
color: Color(0xFFFD879A),
onPressed: () {
// do your navigate here
print("back click");
},
),
【解决方案2】:
appBar: AppBar(
backgroundColor: Colors.transparent,
elevation: 0,
leading: const BackButton(
color: Color(0xFFFD879A),
onPressed: () {
// execute this on pressed...
},
),
),