颤音:Android 12键盘显示空白

发布于 2025-01-25 21:32:45 字数 3060 浏览 3 评论 0原文

我正在在登录屏幕中实现一个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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暖树树初阳… 2025-02-01 21:32:45

这可能是 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文