在uni上为flutter应用程序做UI时,我只希望输入到TextFormField中的文本为白色。似乎不必要地困难。我已经尝试使用谷歌搜索等等,但是看不到明显的答案。
new Theme(
// this colors the underline
data: theme.copyWith(
primaryColor: Colors.white,
hintColor: Colors.transparent,
),
child: new Padding(
padding: const EdgeInsets.fromLTRB(32.0, 40.0, 32.0, 4.0),
child: TextFormField(
key: Key('username'),
keyboardType: TextInputType.text,
controller: usernameController,
decoration: InputDecoration(
fillColor: Colors.black.withOpacity(0.6),
filled: true,
border: new OutlineInputBorder(
borderRadius: const BorderRadius.all(
const Radius.circular(8.0),
),
borderSide: new BorderSide(
color: Colors.transparent,
width: 1.0,
),
),
labelText: 'Username',
labelStyle:
new TextStyle(color: Colors.white, fontSize: 16.0)),
style:
TextStyle(fontSize: 20.0, color: textTheme.button.color),
validator: validateUserName,
onSaved: (val) => this.loginFields._username = val),
),
),
Run Code Online (Sandbox Code Playgroud)
dsh*_*tjr 19
这样做:
TextFormField(
style: TextStyle(
color: Colors.white,
),
)
Run Code Online (Sandbox Code Playgroud)
Kwa*_*edu 14
对于任何尝试从材质应用程序的属性执行此操作的人theme: ThemeData,可以使用文本主题样式更改颜色subtitle1。
MaterialApp(
...
theme: ThemeData(
...
textTheme: const TextTheme(
...
subtitle1: const TextStyle(
color: Colors.red, // <-- TextFormField input color
),
),
),
)
Run Code Online (Sandbox Code Playgroud)
小智 11
您可以在 TextFormField 中使用样式。
TextFormField(
style: const TextStyle(color: Colors.white),
),
Run Code Online (Sandbox Code Playgroud)
你可以用它来改变一切
TextFormField(
//controller: _phoneController,
cursorColor: Colors.black,
keyboardType: TextInputType.text,
style: TextStyle(
color: Colors.black
),
decoration: new InputDecoration(
hintStyle: TextStyle(
color: Colors.white
),
border: InputBorder.none,
//contentPadding:
//EdgeInsets.only(left: 15, bottom: 11, top: 11, right: 15),
hintText: "New Playlist"),
),
Run Code Online (Sandbox Code Playgroud)
小智 5
普韦德斯 style: TextStyle
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Form(
key: _formKey,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
TextFormField(
TextFormField(
controller: field,
style: TextStyle(fontSize: 18, color: Colors.red),
decoration: const InputDecoration(
contentPadding: const EdgeInsets.only(
left: 15,
top: 8,
right: 15,
bottom: 0
),
hintText: 'name',
),
validator: (value) {
if (value.isEmpty) {
return 'Please enter some text';
}
return null;
},
),
)
]
)
)
]
)
)
Run Code Online (Sandbox Code Playgroud)
Arc*_*han -11
为textformfield添加一个inputdecoration类,我是这么认为的
decoration: InputDecoration(
prefixStyle: new TextStyle(
),
Run Code Online (Sandbox Code Playgroud)