参见英文答案 >
Changing EditText bottom line color with appcompat v7 23个
我正在使用Flutter SDK开发应用程序.当我使用
我正在使用Flutter SDK开发应用程序.当我使用
TextField
小部件时,我将其聚焦,下划线变为蓝色.我需要将此颜色更改为红色,我该怎么办?
我需要改变的截图.我只想改变下划线,而不是标签颜色.
解决方法
虽然这些其他答案可能以某种方式起作用,但您绝对不应该使用它.
这不是在Flutter中获得自定义主题的正确方法.
这不是在Flutter中获得自定义主题的正确方法.
一个更优雅的解决方案如下:
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),),);