接收组件列表,常用于盛放若干个按钮。可指定对齐方式、边距等信息。

ButtonBar对齐方式

【alignment】: 对齐方式 【MainAxisAlignment】
【children】: 子组件集 【List
41.gif

  1. import 'package:flutter/material.dart';
  2. import '../../../dialogs/dialog_about.dart';
  3. class CustomButtonBar extends StatelessWidget {
  4. @override
  5. Widget build(BuildContext context) {
  6. return ButtonBar(
  7. alignment: MainAxisAlignment.center,
  8. children: <Widget>[
  9. RaisedButton(
  10. color: Colors.blue,
  11. child: Text("Raised"),
  12. onPressed: () => DialogAbout.show(context)),
  13. OutlineButton(
  14. child: Text("Outline"),
  15. onPressed: () => DialogAbout.show(context)),
  16. FlatButton(
  17. color: Colors.blue,
  18. onPressed: () => DialogAbout.show(context),
  19. child: Text("Flat"),
  20. )
  21. ],
  22. );
  23. }
  24. }

ButtonBar边距和高

【buttonPadding】: 内边距 【EdgeInsetsGeometry】
【buttonHeight】: 高 【double】
42.gif

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"),
        )
      ],
    );
  }
}