示例#1
0
 public ButtonBarTheme(
     Key key = null,
     ButtonBarThemeData data = null,
     Widget child            = null
     ) : base(key: key, child: child)
 {
     D.assert(data != null);
     this.data = data;
 }
示例#2
0
        public override Widget build(BuildContext context)
        {
            ButtonThemeData    parentButtonTheme = ButtonTheme.of(context);
            ButtonBarThemeData barTheme          = ButtonBarTheme.of(context);

            ButtonThemeData buttonTheme = parentButtonTheme.copyWith(
                textTheme: buttonTextTheme ?? barTheme?.buttonTextTheme ?? ButtonTextTheme.primary,
                minWidth: buttonMinWidth ?? barTheme?.buttonMinWidth ?? 64.0f,
                height: buttonHeight ?? barTheme?.buttonHeight ?? 36.0f,
                padding: buttonPadding ?? barTheme?.buttonPadding ?? EdgeInsets.symmetric(horizontal: 8.0f),
                alignedDropdown: buttonAlignedDropdown ?? barTheme?.buttonAlignedDropdown ?? false,
                layoutBehavior: layoutBehavior ?? barTheme?.layoutBehavior ?? ButtonBarLayoutBehavior.padded
                );

            float  paddingUnit = buttonTheme.padding.horizontal / 4.0f;
            Widget child       = ButtonTheme.fromButtonThemeData(
                data: buttonTheme,
                child: new _ButtonBarRow(
                    mainAxisAlignment: alignment ?? barTheme?.alignment ?? MainAxisAlignment.end,
                    mainAxisSize: mainAxisSize ?? barTheme?.mainAxisSize ?? MainAxisSize.max,
                    overflowDirection: overflowDirection ?? barTheme?.overflowDirection ?? VerticalDirection.down,
                    children: LinqUtils <Widget> .SelectList(children, ((Widget childWidget) => {
                return((Widget) new Padding(
                           padding: EdgeInsets.symmetric(horizontal: paddingUnit),
                           child: childWidget
                           ));
            })),
                    overflowButtonSpacing: overflowButtonSpacing
                    )
                );

            switch (buttonTheme.layoutBehavior)
            {
            case ButtonBarLayoutBehavior.padded:
                return(new Padding(
                           padding: EdgeInsets.symmetric(
                               vertical: 2.0f * paddingUnit,
                               horizontal: paddingUnit
                               ),
                           child: child
                           ));

            case ButtonBarLayoutBehavior.constrained:
                return(new Container(
                           padding: EdgeInsets.symmetric(horizontal: paddingUnit),
                           constraints: new BoxConstraints(minHeight: 52.0f),
                           alignment: Alignment.center,
                           child: child
                           ));
            }

            D.assert(false);
            return(null);
        }