[英]How to change the color of the TextField selection
在您的ThemeData
,您可以選擇TextSelectionTheme
(最近的版本已遷移到此,如果您使用舊版本,則屬性是ThemeData
上的單個屬性。 以下是它的文檔和遷移文檔中的示例:
ThemeData(
textSelectionTheme: TextSelectionThemeData(
cursorColor: Colors.red,
selectionColor: Colors.green,
selectionHandleColor: Colors.blue,
)
)
編輯:如果您只想更改單個小部件的主題,您可以使用Theme
小部件包裝您的構建功能,如下所示:
Widget build(BuildContext context) {
return Theme(
child: MyWidget(),
data: ThemeData(
textSelectionTheme: TextSelectionThemeData(
cursorColor: Colors.red,
selectionColor: Colors.green,
selectionHandleColor: Colors.blue,
)));
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.