![](/img/trans.png)
[英]How to change the selected ListTile Icon and Text color in Flutter?
[英]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.