简体   繁体   English

当打开键盘在 Flutter 中显示溢出

[英]When open Keyboard shows overflow in Flutter

In my case, I have a rounded background for all inputs (attached image1) but when I click to the last TextField I get an overflow warning (attached image2) and can't scroll down.就我而言,我的所有输入(附加图像 1)都有一个圆形背景,但是当我单击最后一个 TextField 时,我收到溢出警告(附加图像 2)并且无法向下滚动。

I have tried using in Scaffold resizeToAvoidBottomInset: false but the last TextField goes under the keyboard, so it is not what I want.我曾尝试在 Scaffold resizeToAvoidBottomInset: false中使用,但最后一个 TextField 位于键盘下方,所以这不是我想要的。

my code at gist 我的代码要点

图像1 图2

I think you need to all text field wrap in Listview widget.我认为您需要将所有文本字段包装在Listview小部件中。

wrap you code with SingleChildScrollViewSingleChildScrollView包装你的代码

SingleChildScrollView(
child:Stack(
...))

You can wrap your SingleChildScrollView widget with the Expanded widget.您可以使用Expanded小部件包装SingleChildScrollView小部件。 This is the only thing that you need.这是您唯一需要的。

          Form(
            key: _formKey,
            child: Column(
              mainAxisAlignment: MainAxisAlignment.end,
              mainAxisSize: MainAxisSize.max,
              crossAxisAlignment: CrossAxisAlignment.stretch,
              children: [
                Expanded( // Wrap with Expanded!
                  child: SingleChildScrollView(
                    child: Container(
                      padding: EdgeInsets.symmetric(
                          vertical: 16.0, horizontal: 24.0),
                      decoration: BoxDecoration(
                        color: Colors.white,
                        borderRadius: BorderRadius.only(
                          topLeft: Radius.circular(32.0),
                          topRight: Radius.circular(32.0),
                        ),
                      ),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Row(
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: [
                              Padding(
                                padding:
                                    const EdgeInsets.symmetric(vertical: 16.0),
                                child: Text('Sign Up',
                                    style: TextStyle(
                                        fontSize: 20.0,
                                        fontFamily: 'Montserrat',
                                        fontWeight: FontWeight.bold)),
                              ),
                            ],
                          ),

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM