弹奏键盘覆盖Textfields

发布于 2025-02-09 14:34:43 字数 7873 浏览 1 评论 0原文

我知道这个问题似乎被问到很多,但最终没有得到积极的答案。

我有登录名,注册,Showmodalbottomsheet以及其他一些景点,当Leyboard打开时,它们都不会移动。我开始认为这是扑朔迷离的错误。

我到目前为止尝试的

是包裹在容器,列以及其他一些品种周围的SinglesCrollview,无论我尝试使用哪种尝试,IVE都尝试了SinglesCrollview的任何地方。我还读过,在尝试此操作时不要在任何地方扩展小部件 - 将全屏幕置换:Android构建中的真实选项,这没有改变。 - 在容器和列中进行的Tried ListView,在页面上的其他小部件内外尝试了它们 - 在所有其他测试中,脚手架resizebottominset属性无数次,以查看是否有任何区别以及

  • padding.mediaquery.of(context).viewinsets.bottom.bottom沿着窗口小伙子沿着窗口got树的一堆位置,并且没有更改

Heres Heres我的注册屏幕,我的注册屏幕,我的注册屏幕,没有什么幻想或与众不同的东西

  Widget build(BuildContext context) {
    _deviceHeight = MediaQuery.of(context).size.height;
    _deviceWidth = MediaQuery.of(context).size.width;
    return SafeArea(
      child: Scaffold(
        body: SingleChildScrollView(
          child: Container(
            padding: EdgeInsets.symmetric(
              horizontal: _deviceWidth * 0.03,
              vertical: _deviceHeight * 0.02,
            ),
            width: _deviceWidth * 0.97,
            height: _deviceHeight * 0.98,
            child: Column(
              mainAxisSize: MainAxisSize.min,
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                LoginTitle(
                  title: 'Sign Up',
                  subtitle: 'Create an account...',
                  titleFontSize: 75.sp,
                  subFontSize: 25.sp,
                ),
                SizedBox(height: 10.h),
                buildSignUpForm(),
                SizedBox(height: 20.h),
                Text(
                  'Already have an account?',
                  style: TextStyle(
                    fontSize: 20.sp,
                    color: Colors.orange,
                  ),
                ),
                TextButton(
                  onPressed: () {
                    FocusScope.of(context).unfocus();
                    Get.to(() => LoginScreen());
                  },
                  child: Text(
                    'Sign In',
                    style: TextStyle(
                      color: kSecondaryColor,
                      fontSize: 20.sp,
                    ),
                  ),
                  style: ButtonStyle(
                    overlayColor: MaterialStateColor.resolveWith((states) => Colors.transparent),
                  ),
                ),
                // Padding(
                //   padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
                // ),
              ],
            ),
          ),
        ),
      ),
    );
  }

,也不是在我没有想法的页面上嵌套的buildsignupform

  // Sign-up form Section
  SizedBox buildSignUpForm() {
    return SizedBox(
      height: _deviceHeight * 0.6,
      child: Form(
        key: _signUpFormKey,
        child: Column(
          mainAxisSize: MainAxisSize.min,
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            RoundedTextFormField(
              autoFocus: true,
              focusNode: _nameFocus,
              onFieldSubmitted: _fieldFocusChange(context, _nameFocus, _emailFocus),
              keyboardType: TextInputType.name,
              keyboardAction: TextInputAction.next,
              controller: _nameController,
              hintText: 'Name',
              validator: (value) {
                if (value.toString().length <= 2 || value!.isEmpty) {
                  return 'Enter a valid Name';
                }
                return null;
              },
            ),
            SizedBox(height: _deviceHeight * 0.03),
            RoundedTextFormField(
              focusNode: _emailFocus,
              onFieldSubmitted: _fieldFocusChange(context, _emailFocus, _passwordFocus),
              keyboardType: TextInputType.emailAddress,
              keyboardAction: TextInputAction.next,
              controller: _emailController,
              hintText: 'Email',
              validator: (email) => email != null && !EmailValidator.validate(email) ? 'Enter a valid email' : null,
            ),
            SizedBox(height: _deviceHeight * 0.03),
            RoundedTextFormField(
              focusNode: _passwordFocus,
              onFieldSubmitted: _fieldFocusChange(context, _passwordFocus, _passwordConfirmFocus),
              keyboardType: TextInputType.visiblePassword,
              keyboardAction: TextInputAction.next,
              obsecureText: true,
              controller: _passwordController,
              hintText: 'Password',
              validator: (value) {
                if (value.toString().length < 6 || value!.isEmpty) {
                  return 'Password should be longer or equal to 6 characters.';
                }
                return null;
              },
            ),
            SizedBox(height: _deviceHeight * 0.03),
            RoundedTextFormField(
              focusNode: _passwordConfirmFocus,
              keyboardAction: TextInputAction.send,
              onFieldSubmitted: (_) {
                Utilities.logInfo('Signup Submit button Pressed');
                if (_signUpFormKey.currentState!.validate()) {
                  _signUpFormKey.currentState!.save();
                  setState(() {
                    _isLoading = true;
                  });
                  FocusScope.of(context).unfocus();
                  String name = _nameController.text.trim();
                  String email = _emailController.text.trim();
                  String password = _passwordController.text.trim();

                  Utilities.logInfo('Attempting Signup with Firebase');
                  _authController.signUpWithEmail(name, email, password);
                  setState(() {
                    _isLoading = false;
                  });
                }
              },
              keyboardType: TextInputType.visiblePassword,
              obsecureText: true,
              hintText: 'Confirm Password',
              validator: (value) {
                if (value!.trim() != _passwordController.text.trim() || value.isEmpty) {
                  return 'Passwords do not match!';
                }
                return null;
              },
            ),
            SizedBox(height: _deviceHeight * 0.03),
            _isLoading
                ? const CircularProgressIndicator() // TODO custom progress indicator
                : VextElevatedButton(
                    buttonText: 'Sign Up',
                    onPressed: () {
                      debugPrint('Signup Submit button Pressed');
                      if (_signUpFormKey.currentState!.validate()) {
                        _signUpFormKey.currentState!.save();
                        setState(() {
                          _isLoading = true;
                        });
                        FocusScope.of(context).unfocus();
                        String name = _nameController.text.trim();
                        String email = _emailController.text.trim();
                        String password = _passwordController.text.trim();

                        debugPrint('Attempting Signup with Firebase');
                        _authController.signUpWithEmail(name, email, password);
                        setState(() {
                          _isLoading = false;
                        });
                      }
                    },
                  ),
            SizedBox(height: _deviceHeight * 0.03),
          ],
        ),
      ),
    );
  }
}

,现在开始阅读相同的论坛,网络搜索的结果都在一遍又一遍地尝试相同的事情。我想念什么吗?除了在网络上发布的IVE所看到的帮助或选项以外的任何帮助,都将不胜感激。

哦,我正在使用Dart 2.16.2(稳定)和Flutter 2.10.5请不要让我升级,我从2.2到2.5,并花了几天时间尝试使一切再次工作。然后尝试到3.0,我花了几个小时试图将所有内容降低到工作订单,并把我的整个项目搞砸了大声笑。

I know this questions seems to get asked alot but most of them in the end dont get a positive answer.

I have login, signup, showmodalbottomsheet, and a few other spots where none of them will shift up when the leyboard opens. Im starting to think this is a bug in flutter.

What Ive tried so far

-SingleScrollView wrapped around containers and columns and a few other varieties, anywhere Ive tried singleScrollview doesnt work no matter where I attempt to use it. I also read not to have expanded widget inside anywhere while trying this so I shuffled a screen or two around to remove using them with no result
-removing the fullscreen:true option in the android build manifest and that didnt make a difference.
-tried listview inside containers and columns, tried them inside and out of other widgets on the pages
-the scaffolding resizebottominset property countless times during all the other tests to see if that made any difference as well

  • Padding.mediaquery.of(context).viewInsets.bottom in a bunch of places along the widget tree and no changes

heres my signup screen, nothing fancy or out of the ordinary

  Widget build(BuildContext context) {
    _deviceHeight = MediaQuery.of(context).size.height;
    _deviceWidth = MediaQuery.of(context).size.width;
    return SafeArea(
      child: Scaffold(
        body: SingleChildScrollView(
          child: Container(
            padding: EdgeInsets.symmetric(
              horizontal: _deviceWidth * 0.03,
              vertical: _deviceHeight * 0.02,
            ),
            width: _deviceWidth * 0.97,
            height: _deviceHeight * 0.98,
            child: Column(
              mainAxisSize: MainAxisSize.min,
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                LoginTitle(
                  title: 'Sign Up',
                  subtitle: 'Create an account...',
                  titleFontSize: 75.sp,
                  subFontSize: 25.sp,
                ),
                SizedBox(height: 10.h),
                buildSignUpForm(),
                SizedBox(height: 20.h),
                Text(
                  'Already have an account?',
                  style: TextStyle(
                    fontSize: 20.sp,
                    color: Colors.orange,
                  ),
                ),
                TextButton(
                  onPressed: () {
                    FocusScope.of(context).unfocus();
                    Get.to(() => LoginScreen());
                  },
                  child: Text(
                    'Sign In',
                    style: TextStyle(
                      color: kSecondaryColor,
                      fontSize: 20.sp,
                    ),
                  ),
                  style: ButtonStyle(
                    overlayColor: MaterialStateColor.resolveWith((states) => Colors.transparent),
                  ),
                ),
                // Padding(
                //   padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
                // ),
              ],
            ),
          ),
        ),
      ),
    );
  }

and heres the buildSignUpForm thats nested on the page

  // Sign-up form Section
  SizedBox buildSignUpForm() {
    return SizedBox(
      height: _deviceHeight * 0.6,
      child: Form(
        key: _signUpFormKey,
        child: Column(
          mainAxisSize: MainAxisSize.min,
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            RoundedTextFormField(
              autoFocus: true,
              focusNode: _nameFocus,
              onFieldSubmitted: _fieldFocusChange(context, _nameFocus, _emailFocus),
              keyboardType: TextInputType.name,
              keyboardAction: TextInputAction.next,
              controller: _nameController,
              hintText: 'Name',
              validator: (value) {
                if (value.toString().length <= 2 || value!.isEmpty) {
                  return 'Enter a valid Name';
                }
                return null;
              },
            ),
            SizedBox(height: _deviceHeight * 0.03),
            RoundedTextFormField(
              focusNode: _emailFocus,
              onFieldSubmitted: _fieldFocusChange(context, _emailFocus, _passwordFocus),
              keyboardType: TextInputType.emailAddress,
              keyboardAction: TextInputAction.next,
              controller: _emailController,
              hintText: 'Email',
              validator: (email) => email != null && !EmailValidator.validate(email) ? 'Enter a valid email' : null,
            ),
            SizedBox(height: _deviceHeight * 0.03),
            RoundedTextFormField(
              focusNode: _passwordFocus,
              onFieldSubmitted: _fieldFocusChange(context, _passwordFocus, _passwordConfirmFocus),
              keyboardType: TextInputType.visiblePassword,
              keyboardAction: TextInputAction.next,
              obsecureText: true,
              controller: _passwordController,
              hintText: 'Password',
              validator: (value) {
                if (value.toString().length < 6 || value!.isEmpty) {
                  return 'Password should be longer or equal to 6 characters.';
                }
                return null;
              },
            ),
            SizedBox(height: _deviceHeight * 0.03),
            RoundedTextFormField(
              focusNode: _passwordConfirmFocus,
              keyboardAction: TextInputAction.send,
              onFieldSubmitted: (_) {
                Utilities.logInfo('Signup Submit button Pressed');
                if (_signUpFormKey.currentState!.validate()) {
                  _signUpFormKey.currentState!.save();
                  setState(() {
                    _isLoading = true;
                  });
                  FocusScope.of(context).unfocus();
                  String name = _nameController.text.trim();
                  String email = _emailController.text.trim();
                  String password = _passwordController.text.trim();

                  Utilities.logInfo('Attempting Signup with Firebase');
                  _authController.signUpWithEmail(name, email, password);
                  setState(() {
                    _isLoading = false;
                  });
                }
              },
              keyboardType: TextInputType.visiblePassword,
              obsecureText: true,
              hintText: 'Confirm Password',
              validator: (value) {
                if (value!.trim() != _passwordController.text.trim() || value.isEmpty) {
                  return 'Passwords do not match!';
                }
                return null;
              },
            ),
            SizedBox(height: _deviceHeight * 0.03),
            _isLoading
                ? const CircularProgressIndicator() // TODO custom progress indicator
                : VextElevatedButton(
                    buttonText: 'Sign Up',
                    onPressed: () {
                      debugPrint('Signup Submit button Pressed');
                      if (_signUpFormKey.currentState!.validate()) {
                        _signUpFormKey.currentState!.save();
                        setState(() {
                          _isLoading = true;
                        });
                        FocusScope.of(context).unfocus();
                        String name = _nameController.text.trim();
                        String email = _emailController.text.trim();
                        String password = _passwordController.text.trim();

                        debugPrint('Attempting Signup with Firebase');
                        _authController.signUpWithEmail(name, email, password);
                        setState(() {
                          _isLoading = false;
                        });
                      }
                    },
                  ),
            SizedBox(height: _deviceHeight * 0.03),
          ],
        ),
      ),
    );
  }
}

I'm out of ideas and am now starting to read the same forums results from web searching that are all saying the try the same things over and over. Am I missing something? Any help or options other than the ones Ive seen posted all over the web would be much appreciated.

Oh and I'm using Dart 2.16.2(Stable) and Flutter 2.10.5 Please don't ask me to upgrade, I did that once from 2.2 to 2.5 and spent a few days trying to get it all working again. then tried to 3.0 and I spent a few hours trying to downgrade everything back to working order and messed my whole project up lol.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

巴黎盛开的樱花 2025-02-16 14:34:43

请删除这两行

width: _deviceWidth * 0.97,
            height: _deviceHeight * 0.98,

编辑

包装单个子滚动视图的高度容器:MediaQuery.of(context)。

Please remove these two lines

width: _deviceWidth * 0.97,
            height: _deviceHeight * 0.98,

Edit

Wrap the single child scroll view with a container of height: Mediaquery.of(context).height and width: Mediaquery.of(context).width

胡渣熟男 2025-02-16 14:34:43

因此,经过3个月无法登录并从键盘后面注册屏幕滚动滚动后,我终于弄清楚了。

好吧...藏在我正在寻找的另一种解决方案中的评论中。无论如何,在我的情况下,在我使用MiterateApp或GetMaterialApp的主文件中,有一个称为useInheritedMediaquery的属性。我设定为真。如果您有任何形式的屏幕滚动,请不要使用此操作。当我评论该线路并重新启动我的应用程序时,我为文本场设置设置的每个屏幕现在都在滚动。

So after 3 months of not being able to have my login and sign up screens scroll from behind a keyboard I finally figured it out.

Well... Tucked into a comment from another solution I was looking at. Anyways in the main.dart file where we use MaterialApp or GetMaterialApp in my case, there is a property called useInheritedMediaQuery. I had that set to true. Do not use this if you have any sort of screen scrolling you will want to do. Soon as I commented that line out and restarted my app every screen I had setup for textfields are now scrolling as they should.

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