Flutter防止键盘弹出导致超出屏幕

在做登录时,点击输入用户名的输入框,唤起键盘报错溢出BUG:bottom overflowed by xxx PIXELS

使用SingleChildScrollView包装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
return new Scaffold(
appBar: new AppBar(
title: new Text("搜索"),
),
//使用ScrollView包装一下,否则键盘弹出时会报错空间溢出
body: new SingleChildScrollView(
child: new ConstrainedBox(
constraints: new BoxConstraints(
minHeight: 120.0,
),
child: new Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: <Widget>[
new Padding(
padding: EdgeInsets.fromLTRB(0.0, 40.0, 0.0, 10.0),
child:new Text("注意", style: new TextStyle(fontSize: 18.0,color: Colors.orangeAccent),),
),
],
),
),
),
);

resizeToAvoidBottomPadding设置为false

1
2
3
4
5
6
7
8
return Scaffold(
appBar: AppBar(
elevation: 0.0,
title: new Text("登陆"),
),

resizeToAvoidBottomPadding: false, //输入框抵住键盘
);

Powered by AppBlog.CN     浙ICP备14037229号

Copyright © 2012 - 2020 APP开发技术博客 All Rights Reserved.

访客数 : | 访问量 :