如何将元素设置为SingleCildScrollView的底部?

问题描述 投票:2回答:1

我创建了一个适合列的屏幕,但我需要滚动键盘。我正在使用SingleChildScrollView,但Column的MainAxisAligment在Scrollable中不起作用。

主要问题是 - 我需要在Scrollable的底部设置Widget

我搜索了这个问题并发现了这个:Flutter - SingleChildScrollView interfering in columns但是这个具体问题没有解决办法。

我的代码:

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,
                    ),
                  ),
                )
              ],
            )
          ],
        ),
      );

我想要像this这样的东西,可滚动的内容,因为键盘。但我有this

flutter flutter-layout
1个回答
-1
投票

在顶部的列窗口小部件中包装一个展开的窗口小部件,以便它一直在扩展到底部。然后,将登录按钮放在它下面。键盘不会覆盖您的登录按钮小部件。

© www.soinside.com 2019 - 2024. All rights reserved.