user-interface - 如何在 Flutter 中不使用 AppBar 的情况下添加返回按钮?
解决方案
Simran,这有点棘手,但可以通过Stack
,SingleChildScrollView
和的组合来实现AppBar
。这是演示这一点的快速示例,
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
),),
]),
);
注意:您可以使AppBar
完全透明。但是,您需要相应地设计小部件以确保后退按钮可见。在上面的例子中,我只是设置了不透明度。
希望这可以帮助。祝你好运!
推荐阅读
- android - 如何在 Kotlin 中获取给定 File 实例的拇指图像?
- flutter - 如何在电话号码颤动项目之前添加+号
- python - mysql 在 django.db.backends (django) 中不可用
- java - 如何使用 Spring 安全适配器将语言从网页传递到 Keycloak
- assembly - 首次使用 AVX 256 位向量会减慢 128 位向量和 AVX 标量操作
- image - 以下代码行如何实际降低图像的色度?
- html - 使用 JQuery 嵌套标签
- deep-learning - 如何在训练集中训练没有边界框但有分割标签的detectron2模型
- javascript - 如何使用jquery ajax更改排序箭头升序和降序
- javascript - 增量运算符在 Sequelize 中不起作用