[英]flutter: how to set background for a sliverlist
I've develop an app.There is a page like this:我开发了一个应用程序。有一个这样的页面:
If there are more comments, the picture and comment list can be scroll.So I put them in a CustomScrollView.The question is how can I set background for the SliverList?如果评论多,图片和评论列表可以滚动。所以我把它们放在一个CustomScrollView中。问题是如何为SliverList设置背景?
use this:用这个:
Add a grouping background by customizing the RenderSliver.: https://github.com/mrdaios/flutter_group_sliver通过自定义RenderSliver添加分组背景。: https : //github.com/mrdaios/flutter_group_sliver
flutter_group_sliver: ^0.0.2
You can wrap the 'CustomScrollView' on a Container, and set a color for that Container.您可以将“CustomScrollView”包装在容器上,并为该容器设置颜色。 This is how I solved:
我是这样解决的:
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([]),
)
],
),
);
}
尝试在 Container 中包装 CustomScrollView 并为容器小部件提供颜色。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.