Flutter-另一个小部件下方的位置列表视图 [英] Flutter - Position list view below another widget

查看:46
本文介绍了Flutter-另一个小部件下方的位置列表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从Flutter开始,在一个直观的示例下面,我遇到了一个布局,我在构建时遇到了麻烦:

I'm starting with Flutter, and I came across a layout with which I'm having trouble building, below a visual example:

我已经尝试过类似的事情:

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

但是对于Container,它需要一个高度,我需要它占据屏幕的其余部分.

But for Container it needs a height, and I need it to take up the rest of the screen.

推荐答案

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

这篇关于Flutter-另一个小部件下方的位置列表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆