[英]How to set an element to bottom of SingleCildScrollView?
我创建了一个与列配合良好的屏幕,但是由于键盘的缘故,我需要滚动屏幕。 我正在使用SingleChildScrollView,但是Column的MainAxisAligment在Scrollable内部不起作用。
主要问题是-我需要将Widget设置在Scrollable的底部
我用谷歌搜索了这个问题并发现了这个问题: Flutter-SingleChildScrollView干扰了列,但是没有针对此具体问题的解决方案。
我的代码:
SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: new Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Form(
child: Column(
children: <Widget>[
buildTextField(
'E-mail',
(text) {},
controller: _loginController,
textColor: Theme.of(context).buttonColor,
hintColor: Theme.of(context).hintColor,
margin: EdgeInsets.only(top: 16),
),
buildTextField(
'Password',
(text) {},
focus: _textSecondFocusNode,
controller: _passwordController,
onSubmit: (_) => presenter.login(_loginController.text, _passwordController.text),
textColor: Theme.of(context).buttonColor,
hintColor: Theme.of(context).hintColor,
letterSpacing: 15,
icon: InkWell(
onTap: () {
},
child: Image.asset('assets/ic_eye.png'),
),
margin: const EdgeInsets.only(top: 16),
padding: const EdgeInsets.only(left: 16, top: 4, bottom: 4),
obscureText: true,
),
],
),
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(top: 0),
child: InkWell(
child: Text(
'Registration',
style: TextStyle(color: Theme.of(context).buttonColor, decoration: TextDecoration.underline),
),
onTap: () =>
Navigator.push(context, CupertinoPageRoute(builder: (context) => StartRegistrationScreen())),
),
),
Buttons.buildRaisedButton(
Text(
'Login',
style: TextStyle(color: Colors.white, fontSize: 17, fontFamily: 'SFUIDisplay'),
),
(){},
color: Theme.of(context).buttonColor,
disabledColor: Theme.of(context).disabledColor,
margin: const EdgeInsets.only(top: 16),
),
Padding(
padding: const EdgeInsets.only(top: 16, bottom: 16),
child: Text(
'Forgot password',
style: TextStyle(
color: Theme.of(context).buttonColor,
decoration: TextDecoration.underline,
),
),
)
],
)
],
),
);
将展开的窗口小部件包装在顶部的列窗口小部件中,这样它将一直扩展到底部。 然后,将您的登录按钮置于其下方。 键盘将不会覆盖您的登录按钮小部件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.