Piy*_*ssi 6 dart flutter flutter-layout
我正在尝试在 Flutter 中实现类似的东西。
https://a.imge.to/2019/08/22/mgrjU.png
但我现在被困在这个问题上。
https://a.imge.to/2019/08/22/mgB62.png
操作按钮固定在 UI 的顶部,不随文本移动。有什么办法可以把他们打倒在裂片妖吗?
我一直无法找到向 SliverAppBar 的 flexibleSpace 部分添加操作的方法
SliverAppBar(
floating: false,
pinned: true,
expandedHeight: 150.0,
backgroundColor: Color.fromRGBO(58, 66, 86, 1.0),
flexibleSpace: const FlexibleSpaceBar(
title: Text("User Status", textAlign: TextAlign.justify,),
titlePadding: EdgeInsets.all(15.0),
),
actions: [
IconButton(
icon: Icon(Icons.refresh),
onPressed: () {},
),
IconButton(
icon: Icon(Icons.search),
onPressed: () {},
)
],
);
Run Code Online (Sandbox Code Playgroud)
我希望操作按钮带有标题文本。当用户滚动时,按钮应该随着标题文本移动。
我不确定你是如何做到的,请尝试这个工作代码。
输出:
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color.fromRGBO(58, 66, 86, 1.0),
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
floating: false,
pinned: true,
expandedHeight: 150.0,
backgroundColor: Color.fromRGBO(58, 66, 86, 1.0),
flexibleSpace: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Container(
width: 200,
child: FlexibleSpaceBar(title: Text("User Status")),
),
Spacer(),
IconButton(
icon: Icon(Icons.refresh),
onPressed: () {},
),
IconButton(
icon: Icon(Icons.search),
onPressed: () {},
)
],
),
),
SliverList(
delegate: SliverChildBuilderDelegate((_, i) {
return ListTile(title: Text("Item ${i}"));
}, childCount: 20),
),
],
),
);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3719 次 |
| 最近记录: |