gpt4 book ai didi

dart - 键盘打开时 Flutter 出现溢出错误

转载 作者:IT王子 更新时间:2023-10-29 07:12:13 25 4
gpt4 key购买 nike

我正在设计一个登录页面,当我点击它打开键盘的任何文本表单字段时,它会溢出,并通过这样的溢出警告查看附图。我还希望凸起按钮图标应该位于按钮的右侧。

Widget build(BuildContext context) {
return Container(
child: Scaffold(
body: Stack(
fit: StackFit.expand,
children: <Widget>[
Container(
decoration: BoxDecoration(
image: new DecorationImage(
image: new AssetImage('assets/login_page_bg_1.jpg'),
fit: BoxFit.cover,
colorFilter: new ColorFilter.mode(
Colors.black.withOpacity(0.55), BlendMode.dstATop))),
),
Column(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Expanded(
flex: 1,
child: Container(
margin: new EdgeInsets.only(top: 42.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image.asset('assets/logo.png',
width: 250.0, height: 200.21),
],
),
),
),
Expanded(
flex: 2,
child: Container(
margin: new EdgeInsets.only(bottom: 40.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
//form filed goes here
Text('Login As User',
textAlign: TextAlign.center,
style: TextStyle(
fontWeight: FontWeight.bold, fontSize: 35.0)),
TextFormField(
keyboardType: TextInputType.emailAddress,
decoration: InputDecoration(
hintText: 'you@example.com',
labelText: 'Email Address',
),
new Container(
// width: MediaQuery.of(context).size.width,
child: RaisedButton.icon(
color: Color.fromARGB(251, 188, 74, 1),
label: Text('LOGIN'),
icon: Icon(Icons.send,
size: 10.0, color: Colors.black),
onPressed: () {
this.submit();
}, ),)],),),)],)],),),);

Intital state

Error/overflowed State

最佳答案

将以下属性设置为false

Scaffold(
resizeToAvoidBottomInset: false,
...
)

如果您遇到溢出错误问题,请使用 SingleChildScrollView

Scaffold(
resizeToAvoidBottomInset: false, // set it to false
body: SingleChildScrollView(child: YourBody()),
)

PS:如果你喜欢在键盘打开时滚动你的小部件,你可以看看this answer

关于dart - 键盘打开时 Flutter 出现溢出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55312583/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com