将“文本”窗口小部件放置在嵌入在SingleScrollView

时间:2019-01-15 11:50:12

标签: flutter

我正在设计一个登录屏幕,其中包含登录名和密码TextFormfields,还有一个Inkwell,它可以导航到“注册”页面。我基本上是想在屏幕底部放置一个带有文本小部件(“我的应用程序版本号”)的容器,但是它似乎无法正常工作。我的窗口小部件位于嵌入在SingleScrollView中的列中。该问题似乎是从扩展小部件开始的。衷心欢迎您的帮助。

 @override
Widget build(BuildContext context) {
return new WillPopScope(
    onWillPop: _onWillPop,
    child: new Scaffold(
        key: _scaffoldKey,
        resizeToAvoidBottomPadding: false,
        body: Container(
            color: Colors.blueGrey[900],
            child: Center(
                child: SingleChildScrollView(
                    child: Container(
                        child: Column(
                            mainAxisAlignment: MainAxisAlignment.center,
                            mainAxisSize: MainAxisSize.min,
                               children: <Widget>[
                  Image.asset(
                    'assets/images/op.png',
                    height: 60.0,
                    color: Colors.blueGrey[100],
                  ),
                  new Container(
                    margin: EdgeInsets.all(40.0),
                    child: new Column(children: [
                      Form(
                          key: this.formKey,
                          child: new Column(children: <Widget>[
                            //Username Field
                            Container(
                              margin: EdgeInsets.only(bottom: 20.0),
                              child: new TextFormField(
                                // Retrieve the text the user has typed in using our TextEditingController
                                controller: myEmailController,
                                keyboardType: TextInputType.emailAddress,
                                style: TextStyle(
                                    fontSize: 18.0,
                                    color: Colors.blueGrey[100]),
                                decoration: new InputDecoration(
                                    labelText: 'Email address',
                                    hintStyle: TextStyle(
                                      color: Colors.blueGrey[100],
                                    )),
                                validator: (val) =>
                                    validateEmail(val.trim()),
                                onSaved: (val) => _email = val.trim(),
                              ),
                            ),

                            //Password Field
                            new TextFormField(
                              // Retrieve the password the user has typed in using our TextEditingController
                              controller: myPasswordController,
                              obscureText: true,
                              style: TextStyle(
                                  fontSize: 18.0,
                                  color: Colors.blueGrey[100]),
                              decoration: new InputDecoration(
                                  labelText: 'Password',
                                  hintStyle: TextStyle(
                                    color: Colors.blueGrey[100],
                                  )),
                              validator: validatePassword,
                              onSaved: (val) => _password = val,
                            ),

                            new Container(
                              width: 350,
                              height: 50,
                              margin: EdgeInsets.only(top: 50.0),
                              child: new FlatButton(
                                  color: Colors.blueGrey[800],
                                  child: new Text(
                                    "Sign In",
                                    style: TextStyle(
                                        color: Colors.blueGrey[200],
                                        fontSize: 18),
                                  ),
                                  onPressed: () {
                                    _submit(context);
                                  },
                                  shape: new RoundedRectangleBorder(
                                      // side: BorderSide(color: Colors.white),
                                      borderRadius:
                                          new BorderRadius.circular(30.0))),
                            ),
                            new Container(
                              margin: EdgeInsets.only(top: 20.0),
                              padding: EdgeInsets.all(15.0),
                              child: new InkWell(
                                onTap: () {
                                  Navigator.of(context)
                                      .pushNamed('/register');
                                },
                                child: new Center(
                                  child: new Text(
                                    'New User? Sign Up...',
                                    style: new TextStyle(
                                        fontSize: 16.0,
                                        color: Colors.blueGrey[200]),
                                  ),
                                ),
                              ),
                            ),
                          ])),
                    ]),
                  ),
                  new Expanded(
                      child: new Align(
                         alignment: Alignment.bottomCenter,
                        child: new Container(
                          color: Colors.red,
                          margin: const EdgeInsets.all(0.0),
                          child: new Column(
                            mainAxisAlignment: MainAxisAlignment.end,
                            children: <Widget>[
                              new Align(
                                  alignment: Alignment.bottomCenter,
                                  child: new Container(
                                      padding: EdgeInsets.all(15),
                                      child: new Text(
                                          "Version - " + version,
                                          style: TextStyle(
                                              fontSize: 15,
                                              color:
                                                  Colors.blueGrey[200]))))
                            ],
                          ),
                        ),
                      ))
                ])))))));
  }

0 个答案:

没有答案