颤音:Android 12键盘显示空白
我正在在登录屏幕中实现一个flutter应用程序,以捕获凭据。当我用12.0或带有Android 12的真实设备在Android模拟器上运行它时,它显示了白色容器而不是键盘。它仅在Android 12发生。
接下来我可以尝试什么?
注意:在所有iOS版本上都可以正常工作。
return Form(
key: _formKeySignInInputs,
child: Stack(
children: [
SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(
children: [
Padding(padding: EdgeInsets.fromLTRB(0, 8, 0, 8.vw),
child: buildEmailFormField()),
Padding(padding: EdgeInsets.fromLTRB(0, 0, 0, 2.vw),
child: buildPasswordFormField()),
Padding(padding: EdgeInsets.fromLTRB(2.vw, 0, 0, 4.vw),
],
),
)
],
)
);
}
TextFormField buildPasswordFormField() {
var localeContext = AppLocalizations.of(context)!;
return TextFormField(
autocorrect: false,
obscureText: true,
enableSuggestions: false,
onSaved: (newValue) => password = newValue,
onChanged: (value) {
if (value.isNotEmpty) {
removeError(error: localeContext.password_null_error);
} else if (value.length >= 4) {
removeError(error: localeContext.short_password_error);
}
return;
},
validator: (value) {
if (value!.isEmpty) {
addError(error: localeContext.password_null_error);
return "";
} else if (value.length < 4) {
addError(error: localeContext.short_password_error);
return "";
}
},
decoration: InputDecoration(
labelText: localeContext.password,
hintText: localeContext.password_hint,
floatingLabelBehavior: FloatingLabelBehavior.always,
suffixIcon: const InputFieldSurffixIcon(svgIcon: "assets/icons/password.svg"),
),
);
}
TextFormField buildEmailFormField() {
var localeContext = AppLocalizations.of(context)!;
return TextFormField(
autocorrect: false,
enableSuggestions: false,
keyboardType: TextInputType.emailAddress,
onSaved: (newValue) => email = newValue,
onChanged: (value) {
if (value.isNotEmpty) {
removeError(error: localeContext.email_null_error);
} else if (emailValidatorRegExp.hasMatch(value)) {
removeError(error: localeContext.invalid_email_error);
}
},
validator: (value) {
if (value!.isEmpty) {
addError(error: localeContext.email_null_error);
return "";
} else if (!emailValidatorRegExp.hasMatch(value)) {
addError(error: localeContext.invalid_email_error);
return "";
}
},
decoration: InputDecoration(
labelText: localeContext.email,
hintText: localeContext.email_hint,
floatingLabelBehavior: FloatingLabelBehavior.always,
suffixIcon: const InputFieldSurffixIcon(svgIcon: "assets/icons/temp/mail.svg"),
),
);
}
I am implementing a Flutter app having TextFormField in my login screen to capture credentials. When I ran it on Android Emulator with 12.0 or real device with Android 12 it is showing white container instead of keyboard. It is happening with Android 12 only.
What can I try next?
Note: It is working fine on all iOS Versions.
return Form(
key: _formKeySignInInputs,
child: Stack(
children: [
SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(
children: [
Padding(padding: EdgeInsets.fromLTRB(0, 8, 0, 8.vw),
child: buildEmailFormField()),
Padding(padding: EdgeInsets.fromLTRB(0, 0, 0, 2.vw),
child: buildPasswordFormField()),
Padding(padding: EdgeInsets.fromLTRB(2.vw, 0, 0, 4.vw),
],
),
)
],
)
);
}
TextFormField buildPasswordFormField() {
var localeContext = AppLocalizations.of(context)!;
return TextFormField(
autocorrect: false,
obscureText: true,
enableSuggestions: false,
onSaved: (newValue) => password = newValue,
onChanged: (value) {
if (value.isNotEmpty) {
removeError(error: localeContext.password_null_error);
} else if (value.length >= 4) {
removeError(error: localeContext.short_password_error);
}
return;
},
validator: (value) {
if (value!.isEmpty) {
addError(error: localeContext.password_null_error);
return "";
} else if (value.length < 4) {
addError(error: localeContext.short_password_error);
return "";
}
},
decoration: InputDecoration(
labelText: localeContext.password,
hintText: localeContext.password_hint,
floatingLabelBehavior: FloatingLabelBehavior.always,
suffixIcon: const InputFieldSurffixIcon(svgIcon: "assets/icons/password.svg"),
),
);
}
TextFormField buildEmailFormField() {
var localeContext = AppLocalizations.of(context)!;
return TextFormField(
autocorrect: false,
enableSuggestions: false,
keyboardType: TextInputType.emailAddress,
onSaved: (newValue) => email = newValue,
onChanged: (value) {
if (value.isNotEmpty) {
removeError(error: localeContext.email_null_error);
} else if (emailValidatorRegExp.hasMatch(value)) {
removeError(error: localeContext.invalid_email_error);
}
},
validator: (value) {
if (value!.isEmpty) {
addError(error: localeContext.email_null_error);
return "";
} else if (!emailValidatorRegExp.hasMatch(value)) {
addError(error: localeContext.invalid_email_error);
return "";
}
},
decoration: InputDecoration(
labelText: localeContext.email,
hintText: localeContext.email_hint,
floatingLabelBehavior: FloatingLabelBehavior.always,
suffixIcon: const InputFieldSurffixIcon(svgIcon: "assets/icons/temp/mail.svg"),
),
);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能是 Android 本机子项目中禁用
硬件加速度
功能的问题,有关更多详细信息,请参阅以下问题。It might be the issue of the disabled
Hardware Acceleration
feature in the Android native subproject, for more details, refer to the following question.