user-interface - 如何在 Flutter 中不使用 AppBar 的情况下添加后退按钮?

标签 user-interface flutter dart back-button appbar

关闭。这个问题需要更多focused .它目前不接受答案。












想改善这个问题吗?更新问题,使其仅关注一个问题 editing this post .

1年前关闭。




Improve this question




我想在我的 appBar 上添加一个后退按钮,并想让 appBar 透明,以便它只显示后退按钮。

enter image description here

最佳答案

Simran,这有点棘手,但可以通过 Stack 的组合来实现。 , SingleChildScrollViewAppBar .这是演示这一点的快速示例,

return Scaffold(
              body: Stack(children: <Widget>[
                Container(
                  color: Colors.white,// Your screen background color
                ),
                SingleChildScrollView(
                    child: Column(children: <Widget>[
                      Container(height: 70.0),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                      buildRow('This is test row.'),
                    ])
                ),
                new Positioned(
                  top: 0.0,
                  left: 0.0,
                  right: 0.0,
                  child: AppBar(
                    title: Text(''),// You can add title here
                    leading: new IconButton(
                      icon: new Icon(Icons.arrow_back_ios, color: Colors.grey),
                      onPressed: () => Navigator.of(context).pop(),
                    ),
                    backgroundColor: Colors.blue.withOpacity(0.3), //You can make this transparent
                    elevation: 0.0, //No shadow
                  ),),
              ]),
              );

demo

注意:您可以制作 AppBar完全透明。但是,您需要相应地设计小部件以确保后退按钮可见。在上面的例子中,我只是设置了不透明度。

希望这可以帮助。祝你好运!

关于user-interface - 如何在 Flutter 中不使用 AppBar 的情况下添加后退按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59362570/

相关文章:

android - 如何在Flutter中设置TextSpan的圆角

javascript - 跳过 JavaScript 直接使用 Dart

dart - Dart 列表否定索引不起作用

java - 如何将 JField 设置为 double 值,而不是默认的字符串类型

java - 我正在尝试制作一个按钮来计算文本字段中的字符数

ios - 模拟器的新 Flutter 应用程序构建失败,权限被拒绝

flutter - TabController监听器被多次调用。 indexIsChanging如何工作?

Flutter/Dart - 在我的构建中使用 FutureBuilder 和 Normal 非异步元素?

java - NetBeans 7 中没有 GroupLayout,怎么了?

ios - 标签顶部对齐