flutter 键盘是poping和淡出1秒后,我点击我的文本字段

k4aesqcs  于 2023-05-23  发布在  Flutter
关注(0)|答案(1)|浏览(197)

我做了这个代码通过学习在youtube上,现在我做了同样的youtube教程去在我的手机,只要我点击文本字段我的键盘弹出,但它在1秒内再次褪色感觉就像有人推回来,只要我点击文本字段有人帮我这个

` Widget build(BuildContext context) {
    final controller = Get.put(SignUpController());
    final _formkey = GlobalKey<FormState>();
    return Container(
      padding: const EdgeInsets.symmetric(vertical: tFormHeight - 10),
      child: Form(
        key: _formkey,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            TextFormField(
              controller: controller.fullName,
              decoration: const InputDecoration(
                label: Text(tFullName),
                prefixIcon: Icon(Icons.person_outline_rounded),
              ),
            ),
            SizedBox(height: tFormHeight - 20),
            TextFormField(
              // onTap: () {
              //   FocusNode.requestFocus();
              // },
              // keyboardType: TextInputType.numberWithOptions(signed: true),
              // inputFormatters: [
              //   FilteringTextInputFormatter.digitsOnly,
              // ],
              controller: controller.email,
              decoration: const InputDecoration(
                label: Text(TEmail),
                prefixIcon: Icon(Icons.email_outlined),
              ),
            ),
            SizedBox(height: tFormHeight - 20),
            TextFormField(
              controller: controller.phoneNo,
              decoration: const InputDecoration(
                label: Text(tPhone),
                prefixIcon: Icon(Icons.numbers),
              ),
            ),
            SizedBox(height: tFormHeight - 20),
            TextFormField(
              controller: controller.password,
              decoration: const InputDecoration(
                label: Text(TPassword),
                prefixIcon: Icon(Icons.fingerprint),
              ),
            ),
            SizedBox(height: tFormHeight - 20),
            SizedBox(
              width: double.infinity,
              child: ElevatedButton(
                onPressed: () {
                  if (_formkey.currentState!.validate()) {
                    SignUpController.Instance.registerUser(
                        controller.email.text.trim(),
                        controller.password.text.trim());
                  }
                },
                child: Text(
                  tSignup.toUpperCase(),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }

帮助我克服这个问题,由于这个我的项目正在下降的最后期限,我必须把这个在我的简历感谢阅读到这一点。

q7solyqu

q7solyqu1#

您需要在构建函数之外定义窗体键和控制器

final controller = Get.put(SignUpController());
final _formkey = GlobalKey<FormState>();

Widget build(BuildContext context) {
    return Container(
    ...

相关问题