首页 > 解决方案 > 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),
                  ),

标签: dartflutterflutter-layout

解决方案


把你包ListTile在一个Container

  Container(
        color: Colors.grey[200],
        child: ListTile(
          leading: Icon(
            Icons.person,
            color: Colors.grey,
          ),
          title: Text("Account"),
          trailing: Icon(Icons.keyboard_arrow_right),
        ),
      )

推荐阅读