簡體   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