如何使键盘在扩展小部件的前面

时间:2019-05-22 07:49:06

标签: dart flutter

我建立了一个登录页面,其中包含一个带有两个扩展子元素的股票小部件 第一个扩展具有用户名,密码文本字段和登录按钮,第二个扩展具有注册和忘记密码按钮 发生的事情是,当键盘打开时,第二个扩展出现在键盘上方,并且文本字段并未全部显示在屏幕上

      body: GestureDetector(
        onTap: (){
          FocusScope.of(context).requestFocus(new FocusNode());
        },
        child:   Container(
        child: Column(
          children: <Widget>[

            Expanded(
              flex: 3,
              child: Form(
                key: _formKey,
                child:  ListView(
                shrinkWrap: true,
                padding: EdgeInsets.only(left: 24.0, right: 24.0),
                children: <Widget>[
                  SizedBox(
                    height: spaces,
                  ),
                  loginImage,
                  SizedBox(
                    height: spaces,
                  ),
                  buildUsernameTextField(),
                  SizedBox(
                    height: spaces,
                  ),
                  buildPasswordTextField(),
                  SizedBox(
                    height: spaces,
                  ),
                  login(),
                ],
              ),
              ),

            ),
            Expanded(
              flex: 1,
              child: Container(
                decoration: BoxDecoration(
                    boxShadow: [
                      new BoxShadow(
                        color: Colors.black45,
                        offset: Offset(0.0, -6.0),
                        blurRadius: 10.0,
                      ),
                    ],
                    borderRadius: BorderRadius.only(
                        topLeft: Radius.circular(55),
                        topRight: Radius.circular(55)),
                    gradient: LinearGradient(
                        begin: Alignment.topCenter,
                        end: Alignment.bottomCenter,
                        colors: [
                          const Color(0xFFFF215490),
                          const Color(0xFFFF010431)
                        ],
                        tileMode: TileMode.clamp)),
                child: ListView(
                  shrinkWrap: true,
                  padding: EdgeInsets.only(left: 24, right: 24),
                  children: <Widget>[
                    SizedBox(
                      height: spaces,
                    ),
                    signup(),
                    forgetPassword(),
                    //_buildPasswordTextField(),
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
      ),

    );

enter image description here

enter image description here

如何解决?

1 个答案:

答案 0 :(得分:0)

如果没有,请尝试以下操作:

Scaffold(
    resizeToAvoidBottomInset: false,
),

我已经尝试过了,它可以正常工作,我无法想象为什么它冻结了屏幕

https://maps.googleapis.com/maps/api/geocode/json?&address=%D9%86%D8%AC%D8%B9%20%D8%B3%D8%B9%D9%8A%D8%AF%D8%8C%20%D9%82%D8%B3%D9%85%20%D9%82%D9%86%D8%A7%D8%8C%20%D9%82%D9%86%D8%A7%D8%8C%20Egypt&key=&language=en

enter image description here