colorButtonStyle function
ButtonStyle
colorButtonStyle(})
Implementation
ButtonStyle colorButtonStyle(
Palette sc, {
bool showBorder = true,
TextStyle? textStyle,
double borderWidth = 2,
OutlinedBorder? shape,
required double scale,
}) {
return ButtonStyle(
animationDuration: buttonStyleAnimationDuration,
visualDensity: VisualDensity.compact,
backgroundColor: widgetPropertyByState(
normal: () => sc.color,
hover: () => sc.colorHovered,
splash: () => sc.colorSplashed,
),
surfaceTintColor: widgetPropertyByState(
normal: () => sc.color,
hover: () => sc.colorHovered,
splash: () => sc.colorSplashed,
),
overlayColor: widgetPropertyByState(
normal: () => sc.color,
hover: () => sc.colorHovered,
splash: () => sc.colorSplashed,
),
foregroundColor: widgetPropertyByState(
normal: () => sc.colorText,
hover: () => sc.colorHoveredText,
splash: () => sc.colorSplashedText,
),
iconColor: widgetPropertyByState(
normal: () => sc.colorIcon,
hover: () => sc.colorHoveredIcon,
splash: () => sc.colorSplashedIcon,
),
textStyle: textStyle != null ? WidgetStatePropertyAll(textStyle) : null,
minimumSize: WidgetStatePropertyAll(minimumSizeForScale(scale)),
maximumSize: WidgetStatePropertyAll(maximumSize),
padding: WidgetStatePropertyAll(padding),
shape: shape == null ? null : WidgetStatePropertyAll(shape),
side: showBorder
? WidgetStateProperty.resolveWith((states) {
if (states.contains(WidgetState.pressed) ||
states.contains(WidgetState.dragged)) {
return BorderSide(
color: sc.colorSplashedBorder,
width: borderWidth,
);
}
if (states.contains(WidgetState.hovered) ||
states.contains(WidgetState.focused) ||
states.contains(WidgetState.selected)) {
return BorderSide(
color: sc.colorHoveredBorder,
width: borderWidth,
);
}
return BorderSide(color: sc.colorBorder, width: borderWidth);
})
: null,
);
}