繁体   English   中英

Flutter-键盘打开时会阻止我的文本框

[英]Flutter - when keyboard opens it blocks my textfield

当我在表单中选择文本字段时,键盘会弹出,但它会阻止我键入或进入下一项。

我添加了一个墨水池,以便摆脱它。

此页面从我的脚手架所在的主页加载,并具有底部导航栏,当您单击导航栏时,它将将该页面加载到正文中。

我试图将resizeToAvoidBottomPadding:false添加到支架,然后将代码包装在SingleChildScrollView中,但它不起作用。

@override
  Widget build(BuildContext context) {
    return Center(
      key: scaffoldKey,
      child: InkWell(
          splashColor: Colors.transparent,
          onTap: (){
            FocusScope.of(context).requestFocus(FocusNode());
          },
          child: ListView(
            shrinkWrap: false,
            children: <Widget>[
              Container(
                width: MediaQuery.of(context).size.width,
                height: 150,
                decoration: BoxDecoration(
                  image: DecorationImage(
                    fit: BoxFit.fill,
                    image: AssetImage("assets/images/prayer.png"),
                  ),
                ),
              ),
              Container(
                padding: EdgeInsets.all(15.0),
                child: Text(
                  "Share Your Prayer Request",
                  style: TextStyle(fontSize: 22, fontWeight: FontWeight.bold),
                ),
              ),
              Container(
                padding: EdgeInsets.fromLTRB(15, 0, 15, 0),
                child: Text(
                  "We’d love to pray with you! Please complete the form below to submit your prayer request and our staff will pray for you this week.",
                  style: TextStyle(
                    fontSize: 14,
                  ),
                ),
              ),
              SizedBox(
                height: 10,
              ),
              Form(
                key: _formKey,
                child: Column(
                  children: <Widget>[
                    Container(
                      padding: EdgeInsets.fromLTRB(15, 0, 15, 0),
                      child: Column(
                        children: <Widget>[
                          TextFormField(
                            onSaved: (val) {
                              if (val == '') {
                                newPrayer.name = "Name Not Entered";
                              } else {
                                newPrayer.name = val;
                              }
                            },
                            cursorColor: Colors.lightGreen,
                            keyboardType: TextInputType.text,
                            decoration: InputDecoration(
                                labelText: 'Name',
                                //labelStyle: TextStyle(color: myFocusNode.hasFocus ? Colors.black : Colors.grey),
                                hintText: 'Enter Your First and Last Name',
                                focusedBorder: OutlineInputBorder(
                                    borderSide: BorderSide(color: Colors.lightGreen)),
                                border: OutlineInputBorder(borderSide: BorderSide())),
                          ),
                        ],
                      )

                    ),

...

当我选择一个文本字段时,我真的很想看到页面向上滚动,以便该人可以看到它并转到“提交”按钮。

脚手架不是包含其他页面的页面。 每个页面都需要自己的支架。 因此,如果这是它自己的页面,那么这就是您的问题。 将您的Center小部件包装到其自己的支架中。

暂无
暂无

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

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