默认情况下
Column
小部件填充所有可能的空间。你可以通过它
mainAxisSize
属于
mainAxisSize.min
告诉小部件占用尽可能少的空间。
这是代码的修订版本,可以按您的需要工作:
class MyBottomAppBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
final List<Widget> rowContents = <Widget> [
new FlatButton(
onPressed: () {
},
padding: EdgeInsets.all(10.0),
child: new Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
new Icon(Icons.menu),
new Text("Feed")
],
),
),
const Expanded(child: const SizedBox()),
new FlatButton(
onPressed: () {
},
padding: EdgeInsets.all(10.0),
child: new Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
new Icon(Icons.people),
new Text("Profile")
],
),
),
];
return new BottomAppBar(
hasNotch: true,
child: new Row(children: rowContents),
);
}
}