简体   繁体   中英

Flutter: How do you set the text color for a ListTile that is 'selected'?

I am working on a Flutter app where I am using a drawer. The drawer consists of various menu options using the ListTile class. The documentation specifies that when the 'selected' property of a ListTile is true then 'By default the selected color is the theme's primary color.' but it makes no mention of the text color. Whenever a ListTile is selected the corresponding text changes to blue, which goes against my theme. How do I set the text color for a selected ListTile?

Thanks.

You can apply theme to ListTile by wrapping it with ListTileTheme .

ListTileTheme(
        selectedColor: Colors.red, // text & icon color
        selectedTileColor: Colors.green, // background color
        child: ListTile(
          title: Text('cats')
        )
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM