Gor*_*Cat 6 keyboard colors flutter
在我的 flutter 中,我创建了一个 TextFormField,但它的键盘颜色在 iOS 中是黑色的,我想知道如何将其更改为白色。
颤振语言版本:>=2.2.2 <3.0.0
这是我关于 TextFormField 的代码:
TextFormField(
style: TextStyle(
fontSize: 14,
color: Colors.black),
autofocus: false,
initialValue: 'initial value',
maxLines: 1,
// onSaved: (String value) => _person = value,
// obscureText: _isObscure,
validator: (String value) {
if (value.isEmpty) {
return 'nononono';
}
return null;
},
decoration: InputDecoration(
hintText: 'please make sure',
contentPadding: EdgeInsets.fromLTRB(15, 5, 15, 5),
hintStyle: TextStyle(
color: Colors.grey,
fontSize: 12,
),
hasFloatingPlaceholder: false,
// contentPadding: contentPadding,
border: InputBorder.none,
),
),
Run Code Online (Sandbox Code Playgroud)
当我单击此 TextFormField 时
我得到的是:黑色键盘
我想要的是:白色键盘
白色键盘使用 Brightness.light
黑色键盘使用 Brightness.dark
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TextField(
keyboardType: TextInputType.text,
keyboardAppearance: Brightness.light, // no matter what you set, it simply shows white keyboard
)
],
),
)
Run Code Online (Sandbox Code Playgroud)
如果您用于ThemeData应用程序的全局样式,则可以设置primaryColorBrightness. 如果没有给定值,文本字段的键盘将使用此亮度(亮或暗)keyboardAppearance。
final ThemeData themeDark = ThemeData(
primaryColorBrightness: Brightness.dark,
// ...
);
Run Code Online (Sandbox Code Playgroud)
这样做的优点是您不必keyboardAppearance为每个文本字段进行定义。
请参阅https://api.flutter.dev/flutter/material/TextField/keyboardAppearance.html
| 归档时间: |
|
| 查看次数: |
4034 次 |
| 最近记录: |