我正在使用Ffltter SDK开发一个应用程序.当我使用TextField
小部件并将其聚焦时,下划线变为蓝色.我需要把这个 colored颜色 改成红色,怎么做好呢?
关于我需要更改的内容的屏幕截图.我只想把下划线改一下,, not the label color.
我正在使用Ffltter SDK开发一个应用程序.当我使用TextField
小部件并将其聚焦时,下划线变为蓝色.我需要把这个 colored颜色 改成红色,怎么做好呢?
关于我需要更改的内容的屏幕截图.我只想把下划线改一下,, not the label color.
虽然这些其他答案可能会以某种方式奏效,但你绝对应该not%使用它. 这不是在FLUTH中获得自定义主题的正确方式.
下面是一个更优雅的解决方案:
final theme = Theme.of(context);
return new Theme(
data: theme.copyWith(primaryColor: Colors.red),
child: new TextField(
decoration: new InputDecoration(
labelText: "Hello",
labelStyle: theme.textTheme.caption.copyWith(color: theme.primaryColor),
),
),
);
同时,如果您只想显示错误(红色),请使用InputDecoration
中的errorText
.它会自动将 colored颜色 设置为红色.