flutter - 如何将元素设置到 SingleCildScrollView 的底部?

标签 flutter flutter-layout

我已经创建了一个与列配合良好的屏幕,但由于键盘的原因我需要滚动。我正在使用 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 - 如何将元素设置到 SingleCildScrollView 的底部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54762606/

相关文章:

flutter - Flutter中使用 'body'后, ' bottomNavigationBar'部分不可见

flutter - 用 Dart 条件设置变量

flutter - AppBar 中的扩展小部件

android - 如何在 flutter 中创建 SharedPreferences 的单例类

android - 使用不同参数调用它时的状态小部件更新,而不是更新?

flutter - 如何使用 Flutter 小部件测试器找到 'selected' ListTile?

azure - flutter 应用程序 : How to implement a proper logout function?

dart - Flutter - 如何制作嵌套 ListView ?

flutter - Future<List> 在 Flutter 中列出对象

flutter 如何在点击时动态更改文本颜色?