Exemple #1
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);
        }
Exemple #2
0
        public static ButtonThemeData of(BuildContext context)
        {
            ButtonTheme     inheritedButtonTheme = (ButtonTheme)context.dependOnInheritedWidgetOfExactType <ButtonTheme>();
            ButtonThemeData buttonTheme          = inheritedButtonTheme?.data;

            if (buttonTheme?.colorScheme == null)
            {
                ThemeData theme = Theme.of(context);
                buttonTheme = buttonTheme ?? theme.buttonTheme;
                if (buttonTheme.colorScheme == null)
                {
                    buttonTheme = buttonTheme.copyWith(
                        colorScheme: theme.buttonTheme.colorScheme ?? theme.colorScheme);
                    D.assert(buttonTheme.colorScheme != null);
                }
            }

            return(buttonTheme);
        }