【发布时间】:2020-05-02 23:53:12
【问题描述】:
【问题讨论】:
-
请添加您尝试过的内容。
-
您是希望应用栏缩小然后向上滚动,还是缩小后始终保持可见?
-
@avinash 我正在尝试实现类似于您的图像显示的功能,您能否使其工作?你是怎么做到的?
标签: flutter dart flutter-layout flutter-sliverappbar
【问题讨论】:
标签: flutter dart flutter-layout flutter-sliverappbar
要使用SliverAppBar 并拥有一个缩小并固定在顶部的应用栏,您可以按照以下示例进行操作:
Scaffold(
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
expandedHeight: 200.0,
floating: true,
snap: true,
pinned: true,
flexibleSpace: FlexibleSpaceBar(
title: Text('SliverAppBar 1'),
centerTitle: true,
background: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text('text 1'),
Text('text 2'),
Text('text 3'),
],
),
),
),
SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) {
return Container(
alignment: Alignment.center,
color: Colors.greenAccent,
child: Text('SliverList item'),
height: 60,
margin: EdgeInsets.all(4),
);
},
childCount: 20
),
),
],
)
);
【讨论】: