Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change background color of ListTile?

I am make settings page and want make like iOS settings (grey background and white tile). I am try add Container so can add color to ListTile but always get error.

Anyone know how to add Container here?

  body: new SingleChildScrollView(

        child: Column(

          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: <Widget>[

               Column(

                children: <Widget>[

                  ListTile(
                    leading: Icon(
                      Icons.person,
                      color: Colors.grey,
                    ),
                    title: Text("Account"),
                    trailing: Icon(Icons.keyboard_arrow_right),
                  ),
like image 321
FlutterFirebase Avatar asked Jan 07 '19 21:01

FlutterFirebase


2 Answers

Just wrap your ListTile in a Container

  Container(
        color: Colors.grey[200],
        child: ListTile(
          leading: Icon(
            Icons.person,
            color: Colors.grey,
          ),
          title: Text("Account"),
          trailing: Icon(Icons.keyboard_arrow_right),
        ),
      )
like image 56
diegoveloper Avatar answered Sep 17 '22 17:09

diegoveloper


I wrap the ListTile with a Material widget and set the color. This will preserve the ripple effect of the listTile.

eg.

Material(
        color: Colors.grey[300],
              child: ListTile(
                title: Text('Hello')
              )

    );
like image 29
nonybrighto Avatar answered Sep 17 '22 17:09

nonybrighto