在Scaffold中使用了Column组件,在移动端调出键盘时,报溢出异常问题。

解决方式:

  1. 给Scaffold 添加如下属性
// 用来防止软键盘弹出时遮挡页面的东西。值默认为 true。
// 当设置为 true 的时候,软键盘弹出页面会自动调整尺寸避免遮挡;
// 当为 false 的时候则软键盘弹出不会自动调整尺寸。

resizeToAvoidBottomInset:false    
  1. body中的内容使用SingleChildScrollView包一下
body: SingleChildScrollView(
  child: Column(
    crossAxisAlignment: CrossAxisAlignment.start,
    children: <Widget>[
      _loginTitle(),
      Container(
        height: 400,
        margin: const EdgeInsets.fromLTRB(20, 10, 20, 10),
        decoration: const BoxDecoration(
          color: AppColors.white,
          borderRadius: BorderRadius.all(Radius.circular(8)),
        ),
        child: Stack(
          children: [
            Column(
              children: [
                _textFiled(),
                _autoLogin(),
                _loginButton(),
                _privacy(),
              ],
            ),
          ],
        ),
      ),
    ],
  ),
),

感谢:
flutter - 调出键盘报错溢出异常:bottom overflowed by 80 pixels
Flutter问题:bottom overflowed by 94 pixels

Logo

北京人形旗下天工造物具身智能开源社区,聚焦具身天工与慧思开物两大平台

更多推荐