gpt4 book ai didi

flutter - SingleChildScrollView 'cutting' 屏幕

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

这是我正在开发的登录页面的屏幕:

https://ibb.co/X22g4rc

当键盘出现时,它告诉我有溢出,这似乎是正常的:

https://ibb.co/mzVLJ4f

在网络上进行一些研究后,我发现我必须使用 SingleChildScrollView 小部件,这样当键盘出现时,我才能滚动。据我所知,我必须将它添加到脚手架的 body 属性中。这就是我所做的,并且有效:我能够滚动并且不再有溢出错误消息。

但是:如您所见,显示已被剪切:

https://ibb.co/rHJYqQV

有人知道那是从哪里来的吗?

这是我的代码

return Scaffold(
body:
SingleChildScrollView(child:
Container(
child: Padding(
padding: const EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
SizedBox(
height: 150,
),
Container(
padding: EdgeInsets.only(left: 20.0, right: 20.0),
child: Column(
children: <Widget>[
tabBarContainer,
SizedBox(
height: 20.0,
),

AnimatedContainer(
duration: Duration(seconds: 1),
padding: EdgeInsets.only(top: 40.0, left: 40.0, right: 40.0),
width: double.infinity,
height: _containerHeight,
decoration: cardDecoration,
child: TabBarView(
children: <Widget>[
LoginForm(),
RegisterForm(),
],
)
),

],
),
)
],
),
)
)
)
);

编辑:我也尝试添加 ConstrainedBox,如 api flutter 网站的示例所示,但它对我没有帮助:/

最佳答案

用一个 Expanded 包裹 SingleChildScrollView,他自己包裹在一个 Column 中。

Column(
children:<Widget>[
Expanded(
child:SingleChildScrollView(...)
)
]
)

关于flutter - SingleChildScrollView 'cutting' 屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56664708/

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