textButtonWidget function

Widget textButtonWidget({
  1. required String text,
  2. required VoidCallback? onPressed,
  3. Color? backgroundColor,
  4. Color? disabledBackgroundColor,
  5. Color? textColor,
  6. Color? disabledTextColor,
  7. BorderRadius? borderRadius,
  8. EdgeInsetsGeometry? padding,
  9. EdgeInsetsGeometry? margin,
  10. double fontSize = 14,
  11. Size? minimumSize,
  12. Size? fixedSize,
  13. Size? maximumSize,
  14. FontWeight? fontWeight,
  15. 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,
        ),
      ),
    ),
  );
}