这是我正在开发的登录页面的屏幕:
当键盘出现时,表明存在溢出,这似乎是正常的:
经过对网络的一些研究,我发现我必须使用 SingleChildScrollView
小部件,以便当键盘显示时,我能够滚动。据我所知,我必须将其添加到脚手架的 body
属性中。这就是我所做的,并且它有效:我能够滚动并且不再出现溢出错误消息。
但是:如您所见,显示已被剪切:
有人知道它是从哪里来的吗?
这是我的代码
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/