我想将所有物品垂直放置在容器中,我已经像在Coloum中一样连续放置了孔,但无法像Linear Layout
垂直放置那样垂直放置。
void main() {
runApp(new MaterialApp(
title: "My Demooo2",
home: new MyScaffold(),
));
}
class MyBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Container(
height: 90.0,
margin: new EdgeInsets.symmetric(vertical: 20.0),
padding: new EdgeInsets.all( 8.0),
decoration: new BoxDecoration(color: Colors.blue[100]),
child: new Row(
children: <Widget>[
new IconButton(icon: new Icon(Icons.adjust), onPressed: null),
new IconButton(icon: new Icon(Icons.disc_full), onPressed: null),
new IconButton(icon: new Icon(Icons.scatter_plot), onPressed: null),
new IconButton(icon: new Icon(Icons.delete_forever), onPressed: null),
new Text("test")
],
),
);
}
}
class MyScaffold extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Material(
child: new Column(
children: <Widget>[
new MyBar(),
new Expanded(
child: new Center(
child: new Text("My Center"),
))
],
),
);
}
}
答案 0 :(得分:0)
我不知道您的确切布局要求-如果我理解您的问题-请尝试以下代码:
class MyBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Container(
// height: 90.0,
margin: new EdgeInsets.symmetric(vertical: 20.0),
padding: new EdgeInsets.all( 8.0),
decoration: new BoxDecoration(color: Colors.blue[100]),
child: new Column(
children: <Widget>[
new IconButton(icon: new Icon(Icons.adjust), onPressed: null),
new IconButton(icon: new Icon(Icons.disc_full), onPressed: null),
new IconButton(icon: new Icon(Icons.scatter_plot), onPressed: null),
new IconButton(icon: new Icon(Icons.delete_forever), onPressed: null),
new Text("test")
],
),
);
}
}
class MyScaffold extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Material(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new MyBar(),
new Expanded(
child: new Center(
child: new Text("My Center"),
))
],
),
);
}
}
输出: