【问题标题】: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...
          },
        ),
      ),
    

    【讨论】:

      猜你喜欢
      • 2014-11-21
      • 2019-01-16
      • 1970-01-01
      • 2023-03-22
      • 2018-06-09
      • 1970-01-01
      • 1970-01-01
      • 2021-05-24
      • 1970-01-01
      相关资源
      最近更新 更多