Flutter 如何设置输入装饰的OutlineInputBorder的样式?
我正在尝试设置Flutter 如何设置输入装饰的OutlineInputBorder的样式?,flutter,Flutter,我正在尝试设置TextFormField的边框样式。我将它与大纲输入框一起使用。默认情况下,它采用近乎黑色的颜色,聚焦时采用原色。我试图更改边框的颜色,但无效 我还尝试了在forUnderlineInputBorder中提到的解决方法,但没有任何变化 new TextFormField( decoration: new InputDecoration( labelText: "Email", contentPadding: new EdgeInsets.a
TextFormField
的边框样式。我将它与大纲输入框一起使用。默认情况下,它采用近乎黑色的颜色,聚焦时采用原色。我试图更改边框的颜色,但无效
我还尝试了在forUnderlineInputBorder
中提到的解决方法,但没有任何变化
new TextFormField(
decoration: new InputDecoration(
labelText: "Email",
contentPadding: new EdgeInsets.all(12.0),
filled: true,
border: new OutlineInputBorder(
borderSide: new BorderSide(width: 2.0, color: Colors.white),
)
),
),
在深入挖掘之后,似乎只能通过主题数据进行配置。所以我只是添加了一个主题小部件
body: Theme(data: Theme.of(context).copyWith(
primaryColor: Colors.white,
accentColor: Colors.amber
), child: new TextFormField(
decoration: new InputDecoration(
labelText: "Email",
contentPadding: new EdgeInsets.all(12.0),
),
),
输入(u decorator.dart#1440-1450
您只想更改边框颜色?要设置哪种颜色?边框和标签颜色。
Color _getActiveColor(ThemeData themeData) {
if (isFocused) {
switch (themeData.brightness) {
case Brightness.dark:
return themeData.accentColor;
case Brightness.light:
return themeData.primaryColor;
}
}
return themeData.hintColor;
}