Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flutter: how to set background for a sliverlist

Tags:

flutter

I've develop an app.There is a page like this:

screenshot

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?

like image 332
user3005122 Avatar asked Mar 16 '19 08:03

user3005122


2 Answers

use this:

Add a grouping background by customizing the RenderSliver.: https://github.com/mrdaios/flutter_group_sliver

flutter_group_sliver: ^0.0.2
like image 38
user3005122 Avatar answered Oct 01 '22 20:10

user3005122


You can wrap the 'CustomScrollView' on a Container, and set a color for that Container. 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([]),
          )
        ],
      ),
    );
  }
like image 69
Jorge Sánchez Avatar answered Oct 01 '22 22:10

Jorge Sánchez