textButtonWidget function
Widget
textButtonWidget({
- required String text,
- required VoidCallback? onPressed,
- Color? backgroundColor,
- Color? disabledBackgroundColor,
- Color? textColor,
- Color? disabledTextColor,
- BorderRadius? borderRadius,
- EdgeInsetsGeometry? padding,
- EdgeInsetsGeometry? margin,
- double fontSize = 14,
- Size? minimumSize,
- Size? fixedSize,
- Size? maximumSize,
- FontWeight? fontWeight,
- AlignmentGeometry? alignment,
Implementation
Widget textButtonWidget({
required String text,
required VoidCallback? onPressed,
Color? backgroundColor,
Color? disabledBackgroundColor,
Color? textColor,
Color? disabledTextColor,
BorderRadius? borderRadius,
EdgeInsetsGeometry? padding,
EdgeInsetsGeometry? margin,
double fontSize = 14,
Size? minimumSize,
Size? fixedSize,
Size? maximumSize,
FontWeight? fontWeight,
AlignmentGeometry? alignment,
}) {
return Padding(
padding: margin ?? EdgeInsets.zero,
child: TextButton(
onPressed: onPressed,
style: TextButton.styleFrom(
backgroundColor: backgroundColor ?? Colors.blue,
disabledBackgroundColor: disabledBackgroundColor ?? Colors.grey,
shape: RoundedRectangleBorder(
borderRadius: borderRadius ?? BorderRadius.circular(8.r),
),
padding: padding ?? EdgeInsets.zero,
minimumSize: minimumSize,
fixedSize: fixedSize,
maximumSize: maximumSize,
alignment: alignment,
),
child: Text(
text,
style: TextStyle(
color: onPressed != null
? textColor ?? Colors.white
: disabledTextColor ?? Colors.black38,
fontSize: fontSize.sp,
fontWeight: fontWeight,
),
),
),
);
}