我开发了一个应用程序。有一个这样的页面:
如果评论多了,图片和评论列表可以滚动。所以我把它们放在CustomScrollView中。问题是如何为SliverList设置背景?
小智 12
您可以将“CustomScrollView”包装在容器上,并为该容器设置颜色。我是这样解决的:
Widget build(BuildContext context) {
return Container(
color: Colors.white,
child: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
title: Text('Title'),
expandedHeight: 100.0,
flexibleSpace: FlexibleSpaceBar(),
),
SliverList(
delegate: SliverChildListDelegate([]),
)
],
),
);
}
Run Code Online (Sandbox Code Playgroud)
用这个:
通过自定义RenderSliver添加分组背景。:https://github.com/mrdaios/flutter_group_sliver
flutter_group_sliver: ^0.0.2
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
11674 次 |
| 最近记录: |