【发布时间】:2021-04-04 19:57:55
【问题描述】:
我有一个TextField,目前看起来像这样:
如您所见,所选颜色为紫色。但是我怎样才能改变那个特定 TextField 的颜色呢?我不想更改AppThemeData。我在这方面找不到任何东西...很高兴为您提供帮助!
【问题讨论】:
标签: flutter dart colors textfield
我有一个TextField,目前看起来像这样:
如您所见,所选颜色为紫色。但是我怎样才能改变那个特定 TextField 的颜色呢?我不想更改AppThemeData。我在这方面找不到任何东西...很高兴为您提供帮助!
【问题讨论】:
标签: flutter dart colors textfield
您可以尝试用Theme 包装它,然后使用SplashColor 变成这样:
Theme(
data: ThemeData(textSelectionColor: Colors.green),
child: TextField(
autofocus: false,
decoration: InputDecoration(
filled: true,
fillColor: Colors.white,
hintText: 'Mail',
),
),
);
或在 main 中执行此操作:
theme: ThemeData(
accentColor: Color(0xffBA379B).withOpacity(.6),
primaryColor: Color(0xffBA379B),
textSelectionTheme: TextSelectionThemeData(
selectionColor: Color(0xffBA379B).withOpacity(.5),
cursorColor: Color(0xffBA379B).withOpacity(.6),
selectionHandleColor: Color(0xffBA379B).withOpacity(1),
),
```
【讨论】:
fillColor。我想更改副本/选定的颜色。选择文字时出现图片中的紫色
textSelectionColor 已弃用 :(