styleButtonRounded function
Creates a rounded ButtonStyle used by XButton.
This method allows defining background color, foreground color, border, padding, elevation, and radius.
Typically used internally by XButton, but can also be used independently.
Example:
styleButtonRounded(
radius: 12,
background: Colors.blue,
);
Implementation
ButtonStyle styleButtonRounded({
double radius = 10,
Color? background,
Color? foreground,
Color? borderColor,
bool? isEnable = true,
double elevation = 1,
double paddingHorizontal = 12,
double paddingVertical = 5,
double borderWidth = 0,
}) {
final bgColor = isEnable == false
? Colors.grey[300]
: background ?? Colors.lightBlue;
final fgColor = foreground ?? Colors.white;
ButtonStyle buttonStyle =
ElevatedButton.styleFrom(
minimumSize: const Size(80, 48),
backgroundColor: bgColor,
foregroundColor: fgColor,
elevation: elevation,
textStyle: TextStyle(color: fgColor),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(radius),
side: borderColor != null
? BorderSide(color: borderColor, width: borderWidth)
: BorderSide.none,
),
).copyWith(
padding: WidgetStateProperty.all<EdgeInsets>(
EdgeInsets.symmetric(
horizontal: paddingHorizontal,
vertical: paddingVertical,
),
),
);
return buttonStyle;
}