Flutter问题:bottom overflowed by 94 pixels

一、问题描述

在搭建 Flutter 页面布局的时候报错:bottom overflowed by 94 pixels,报错截图如下:

二、关键代码

return Padding(
      padding: EdgeInsets.only(left: 50.0, top: 70.0, right: 50.0, bottom: 38.0),
      child: Column (
        children: <Widget>[
          Padding (
            child: Icon(Icons.drive_eta, color: AppColors.Green, size: 90.0,),
            padding: EdgeInsets.only(bottom: 184.0),
          ),
          TextField(),
        ],
      ),
    );

三、解决方案

给 Scaffold 添加如下配置:

resizeToAvoidBottomInset: false

搞定 !

这时候我们会有所疑问,这个属性是用来干什么的呢 ? 

我们看一下官方文档注释:

  /// If true the [body] and the scaffold's floating widgets should size
  /// themselves to avoid the onscreen keyboard whose height is defined by the
  /// ambient [MediaQuery]'s [MediaQueryData.viewInsets] `bottom` property.
  ///
  /// For example, if there is an onscreen keyboard displayed above the
  /// scaffold, the body can be resized to avoid overlapping the keyboard, which
  /// prevents widgets inside the body from being obscured by the keyboard.
  ///
  /// Defaults to true.
  final bool resizeToAvoidBottomInset;

大致意思是:

这个属性是用来防止软键盘弹出时遮挡页面的东西。当设置为 true 的时候,软键盘弹出页面会自动调整尺寸避免遮挡; 当为 false 的时候则软键盘弹出不会自动调整尺寸。该属性值默认为 true。

四、参考文献

发布了179 篇原创文章 · 获赞 91 · 访问量 33万+

猜你喜欢

转载自blog.csdn.net/haha223545/article/details/102547931
94
今日推荐