加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

mobile – Flutter – 位于另一个小部件下方的列表视图

发布时间:2020-12-14 14:58:42 所属栏目:百科 来源:网络整理
导读:我是从Flutter开始的,我遇到了一个我无法构建的布局,在一个可视化示例下面: 我已经尝试过类似的东西: class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return new MaterialApp( title: 'Welcome to Flutter',home:
我是从Flutter开始的,我遇到了一个我无法构建的布局,在一个可视化示例下面:

enter image description here

我已经尝试过类似的东西:

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来说它需要一个高度,我需要它来占据屏幕的其余部分.

解决方法

new Column(
    children: <Widget>[
        new Text('LISTA',style: new TextStyle(
            fontSize: 15.2,)),new Expanded(
            child: new Container(
                decoration: new BoxDecoration(color: Colors.blue),height: 200.0,child: new ListView(
                    children: <Widget>[
                        new RaisedButton(
                            onPressed: null,new RaisedButton(
                            onPressed: null,)
                    ],)
        )
    ]
)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读