简体   繁体   English

Flutter - 另一个小部件下方的位置列表视图

[英]Flutter - Position list view below another widget

I'm starting with Flutter, and I came across a layout with which I'm having trouble building, below a visual example:我从 Flutter 开始,我遇到了一个我在构建时遇到问题的布局,下面是一个可视化示例:

在此处输入图像描述

I already tried something like:我已经尝试过类似的东西:

        class MyApp extends StatelessWidget {
          @override
          Widget build(BuildContext context) {
            return new MaterialApp(
              title: 'Welcome to Flutter',
              home: new Scaffold(
                  appBar: new AppBar(
                    title: new Text('App'),
                  ),
                  body: new Column(
                      children: <Widget>[
                        new Text('LISTA',
                            style: new TextStyle(
                              fontSize: 15.2,
                              fontWeight: FontWeight.bold,
                            )
                        ),
                        new Container(
                          height: 200.0,
                          child: new ListView(
                            children: <Widget>[
                              new RaisedButton(
                                onPressed: null,
                                child: new Text("text button"),
                              ),
                              new Padding(padding: new EdgeInsets.all(5.00)),
                              new RaisedButton(
                                onPressed: null,
                                child: new Text("text button 2"),
                              )
                            ],
                          ),
                        )
                      ]
                  )
              ),
            );
          }
        }

But for Container it needs a height, and I need it to take up the rest of the screen.但是对于 Container 它需要一个高度,我需要它占据屏幕的其余部分。

new Column(
    children: <Widget>[
        new Text('LISTA', style: new TextStyle(
            fontSize: 15.2,
            fontWeight: FontWeight.bold,
        )),
        new Expanded(
            child: new Container(
                decoration: new BoxDecoration(color: Colors.blue),
                child: new ListView(
                    children: <Widget>[
                        new RaisedButton(
                            onPressed: null,
                            child: new Text("text button"),
                        ),
                        new Padding(padding: new EdgeInsets.all(5.00)),
                        new RaisedButton(
                            onPressed: null,
                            child: new Text("text button 2"),
                        )
                    ],
                ),
            )
        )
    ]
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM