【问题标题】:key board hinding screen in flutter颤动中的键盘隐藏屏幕
【发布时间】:2021-02-16 19:36:51
【问题描述】:

这里是代码[在此处输入图片描述[][1]][1]

嘿,我正在开发一个新的应用程序,它有一个评论部分显示我把文本字段放在底部是因为更好的视图但是每当我打开键盘时我的半屏就会隐藏起来,这非常 对用户界面不好,所以在这里我需要你的帮助,当我使 resizeToAvoidBottomInset 错误文本字段隐藏在键盘后面时

      appBar: AppBar(
        elevation: 0.0,
        title: Text(
          "Comments",
          style: TextStyle(color: Colors.black),
        ),
      ),
      body: Column(children: [
        Expanded(
          child: Obx(
            () => ListView.builder(
                itemCount: controller.comments.length,
                itemBuilder: (BuildContext context, int index) {
                  return Comment(
                      comment: controller.comments[index]['comment'],
                      userid: controller.comments[index]['userid']);
                }),
          ),
        ),
        Spacer(),
        Container(
          height: 50,
          child: CupertinoTextField(
            
            controller: controller.postComment,
            padding: const EdgeInsets.all(8),
            prefix: IconButton(
              onPressed: () {},
              icon: Icon(Icons.emoji_emotions),
            ),
            //  decoration: BoxDecoration(border: Border.all()),
            suffix: IconButton(
              icon: Icon(Icons.send),
              onPressed: () {
                controller.addComment(
                    args, FirebaseAuth.instance.currentUser.uid);
              },
            ),
            placeholder: "Enter a Comment",
          ),
        )
      ]),
    );    ```


  [1]: https://i.stack.imgur.com/FER2u.png

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    如果您想在显示键盘时使列内的内容可滚动,我相信您可以使用SingleChildScrollView。以下是使用示例:

    SingleChildScrollView( 
      child: Column(
        children: <Widget>[
          Container(
            height: 250,
            color: Colors.red[600],
            child: const Center(child: Text('Entry A')),
          ),
          Container(
            height: 250,
            color: Colors.red[500],
            child: const Center(child: Text('Entry B')),
          ),
          Container(
            height: 250,
            color: Colors.yellow[100],
            child: const Center(child: Text('Entry C')),
          ),
        ],
      ),
    )
    

    【讨论】:

    • 但是我有一个展开的列表视图,如果包裹在 singlechildscrollview 中会报错
    • 它可以在没有扩展的情况下工作我必须使用媒体查询但我想知道我可以在没有媒体查询的情况下使用
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-28
    • 2015-04-13
    • 1970-01-01
    • 2015-01-04
    • 2015-06-12
    相关资源
    最近更新 更多