如何在 Flutter 中将 ListView 添加到列? - How to add a ListView to a Column in Flutter?

问题:

I'm trying to construct a simple login page for my Flutter app.我正在尝试为我的 Flutter 应用程序构建一个简单的登录页面。 I've successfully built the TextFields and log in/Sign in buttons.我已经成功构建了 TextFields 并登录/登录按钮。 I want to add a horizontal ListView.我想添加一个水平的 ListView。 When I run the code my elements disappear, if I do it without the ListView, it's fine again.当我运行代码时,我的元素消失了,如果我在没有 ListView 的情况下执行此操作,则再次正常。 How can I do this correctly?我怎样才能正确地做到这一点?

return new MaterialApp(
        home: new Scaffold(
          appBar: new AppBar(
            title: new Text("Login / Signup"),
          ),
          body: new Container(
            child: new Center(
              child: new Column(
              mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  new TextField(
                    decoration: new InputDecoration(
                      hintText: "E M A I L    A D D R E S S"
                    ),
                  ),
                  new Padding(padding: new EdgeInsets.all(15.00)),
                  new TextField(obscureText: true,
                    decoration: new InputDecoration(
                      hintText: "P A S S W O R D"
                    ),
                    ),
                  new Padding(padding: new EdgeInsets.all(15.00)),
                  new TextField(decoration: new InputDecoration(
                    hintText: "U S E R N A M E"
                  ),),
                  new RaisedButton(onPressed: null,
                  child:  new Text("SIGNUP"),),
                  new Padding(padding: new EdgeInsets.all(15.00)),
                  new RaisedButton(onPressed: null,
                  child: new Text("LOGIN"),),
                  new Padding(padding: new EdgeInsets.all(15.00)),
                  new ListView(scrollDirection: Axis.horizontal,
                  children: <Widget>[
                    new RaisedButton(onPressed: null,
                    child: new Text("Facebook"),),
                    new Padding(padding: new EdgeInsets.all(5.00)),
                    new RaisedButton(onPressed: null,
                    child: new Text("Google"),)
                  ],)

                ],
              ),
            ),
            margin: new EdgeInsets.all(15.00),
          ),
        ),
      );

解决方案:

参考一: https://stackoom.com/question/35ce2
参考二: How to add a ListView to a Column in Flutter?
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章