繁体   English   中英

Flutter:如何为“选定”的 ListTile 设置文本颜色?

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

我正在使用一个抽屉的 Flutter 应用程序。 抽屉由使用 ListTile class 的各种菜单选项组成。 文档指定当 ListTile 的“选定”属性为真时,“默认情况下,选定颜色是主题的原色。” 但它没有提及文本颜色。 Whenever a ListTile is selected the corresponding text changes to blue, which goes against my theme. 如何为选定的 ListTile 设置文本颜色?

谢谢。

您可以通过使用 ListTileTheme 包装主题来将主题应用于ListTile

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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