当在Flutter TextField中可见键盘时,键盘顶部有很多空白 [英] Lot of blank space on top of keyboard when keyboard is visible in Flutter TextField

查看:652
本文介绍了当在Flutter TextField中可见键盘时,键盘顶部有很多空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

build(BuildContext context) {
  return new Scaffold(
    body: new SafeArea(
    child: new ListView.builder(
        itemBuilder: (itemBuilder),
      itemCount: (1),
      padding: kMaterialListPadding,
    ),
  )
 );
}
itemBuilder(BuildContext context, int index) {
    return new TextFormField(
        decoration: new InputDecoration(
          border: const OutlineInputBorder(),
          hintText: "What's on your mind?",
          helperText: "5-500 characters",
        ),
        maxLines: 3,
    );
}

当我点击文本字段时,键盘会打开,但是在键盘顶部会出现很多空白,就像您在图片中看到的那样(文本字段的边框被切掉了).

When I tap on the text field, keyboard opens but lot of blank space appears on top of keyboard as you can see in the picture (border of textfield is cut).

它是由于ListView而发生的.如果仅在正文中添加文本字段,外观就很好.

It happens because of the ListView. If I add just the text field to the body, appearance is fine.

推荐答案

浪费大量空间的原因是因为脚手架内部有一个脚手架.每个支架都为键盘增加了空间.删除一个就解决了这个问题.

The reason for lot of wasted space was because there was a Scaffold inside a Scaffold. Each scaffold adding space for keyboard. Removing one solved the problem.

这篇关于当在Flutter TextField中可见键盘时,键盘顶部有很多空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆