接收组件列表,常用于盛放若干个按钮。可指定对齐方式、边距等信息。
ButtonBar对齐方式
【alignment】: 对齐方式 【MainAxisAlignment】
【children】: 子组件集 【List
import 'package:flutter/material.dart';
import '../../../dialogs/dialog_about.dart';
class CustomButtonBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ButtonBar(
alignment: MainAxisAlignment.center,
children: <Widget>[
RaisedButton(
color: Colors.blue,
child: Text("Raised"),
onPressed: () => DialogAbout.show(context)),
OutlineButton(
child: Text("Outline"),
onPressed: () => DialogAbout.show(context)),
FlatButton(
color: Colors.blue,
onPressed: () => DialogAbout.show(context),
child: Text("Flat"),
)
],
);
}
}
ButtonBar边距和高
【buttonPadding】: 内边距 【EdgeInsetsGeometry】
【buttonHeight】: 高 【double】
import 'package:flutter/material.dart';
import '../../../dialogs/dialog_about.dart';
class PaddingButtonBar extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ButtonBar(
alignment: MainAxisAlignment.center,
buttonHeight: 40,
buttonPadding: EdgeInsets.only(left: 15,right: 15),
children: <Widget>[
RaisedButton(
color: Colors.blue,
child: Text("Raised"),
onPressed: () => DialogAbout.show(context)),
OutlineButton(
child: Text("Outline"),
onPressed: () => DialogAbout.show(context)),
FlatButton(
color: Colors.blue,
onPressed: () => DialogAbout.show(context),
child: Text("Flat"),
)
],
);
}
}