【问题标题】:Lot of blank space on top of keyboard when keyboard is visible in Flutter TextField当 Flutter TextField 中的键盘可见时,键盘顶部有很多空白区域
【发布时间】:2018-09-10 01:58:35
【问题描述】:

这是我的代码:

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,
    );
}

当我点击文本字段时,键盘会打开,但键盘顶部会出现很多空白,如图所示(文本字段的边框被剪掉)。

它的发生是因为 ListView。如果我只将文本字段添加到正文中,则外观很好。

【问题讨论】:

    标签: flutter


    【解决方案1】:

    大量浪费空间的原因是脚手架里面有一个脚手架。每个脚手架都为键盘增加了空间。删除一个解决了问题。

    【讨论】:

      【解决方案2】:

      Scaffold 有一个属性 resizeToAvoidBottomPadding。 将此属性设置为 false

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-09-18
        • 2020-06-22
        • 2017-06-01
        • 2019-03-08
        • 2021-10-06
        • 1970-01-01
        • 2021-04-07
        相关资源
        最近更新 更多