【问题标题】:Flutter: How do you set the text color for a ListTile that is 'selected'?Flutter:如何为“选定”的 ListTile 设置文本颜色?
【发布时间】:2021-08-25 20:20:13
【问题描述】:

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

谢谢。

【问题讨论】:

    标签: flutter


    【解决方案1】:

    您可以将主题应用到 ListTile,方法是用 ListTileTheme 包装它。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-13
      • 2021-09-11
      • 1970-01-01
      相关资源
      最近更新 更多