[英]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.