Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter - Position list view below another widget

Tags:

mobile

flutter

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

enter image description here

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.

like image 722
Paulo Gonçalves Avatar asked Mar 14 '18 18:03

Paulo Gonçalves


1 Answers

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"),
                        )
                    ],
                ),
            )
        )
    ]
)
like image 90
Paulo Gonçalves Avatar answered Nov 10 '22 09:11

Paulo Gonçalves