【发布时间】:2019-12-29 00:05:51
【问题描述】:
我有一个TextFormField,它有一个返回字符串的验证器。我想以红色显示验证错误消息,并且可能是其他样式
- 如何更改其颜色?
-
我可以在 Theme 中配置它,以便我可以为我的应用程序中的所有表单配置一次吗?
TextFormField(
TextFormField(
textCapitalization: TextCapitalization.words,
decoration: InputDecoration(
border: UnderlineInputBorder(),
filled: true,
icon: Icon(Icons.person),
hintText: 'First name',
labelText: 'First Name *',
),
onSaved: (String value) {
this._customer.fName = value;
},
validator: _validateName,
initialValue: this._customer.fName,
),
编辑1:
我在 ThemeData 中添加了以下内容。
final ThemeData myTheme = ThemeData(
errorStyle: TextStyle(
color: Colors.red,
fontSize: null,
fontWeight: FontWeight.w400,
fontStyle: FontStyle.normal,
),
errorColor: Color(0xffd32f2f),
)
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Lead Manager',
theme: myTheme,
home: Home(),
);
}
}
但它不起作用。
【问题讨论】:
标签: flutter