我从Flutter开始,在一个视觉示例下面,我遇到了一个我无法构建的布局:
我已尝试过类似的内容:
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来说,它需要一个高度,我需要它来占据屏幕的其余部分。
答案 0 :(得分:6)
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),
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"),
)
],
),
)
)
]
)