写好了,感觉可好
点击输入框,输入内容时发现如下,键盘遮挡了输入框
使用 SingleChildScrollView 解决遮挡问题, 就是让它滚动起来
直接使用 SingleChildScrollView 包裹子元素
class MyHomePage extends StatelessWidget {
@override
Widget
build(BuildContext context
) {
return Scaffold(
backgroundColor
: Color(0xFFcccccc),
body
: SingleChildScrollView(
child
: Column(
children
: [
Container(
height
: 200,
color
: Colors
.black12
,
child
: Center(child
: Text("顶部")),
),
SizedBox(height
: 20),
Container(
height
: 200,
margin
: EdgeInsets
.all(10),
width
: double
.infinity
,
color
: Colors
.white
,
child
: Column(
children
: [
Container(
height
: 40,
width
: 250,
margin
: EdgeInsets
.all(10),
child
: TextField(
decoration
: InputDecoration(
fillColor
: Color(0xffcfcccc),
filled
: true,
hintText
: '请输入账号',
contentPadding
: EdgeInsets
.only(left
: 20),
),
),
),
Container(
height
: 40,
width
: 250,
margin
: EdgeInsets
.all(10),
child
: TextField(
decoration
: InputDecoration(
fillColor
: Color(0xfffdfccc),
filled
: true,
hintText
: '请输入密码',
contentPadding
: EdgeInsets
.only(left
: 20),
),
),
)
],
),
),
],
),
),
);
}
转载请注明原文地址: https://lol.8miu.com/read-1425.html