customFlatButton function

TextButton customFlatButton({
  1. required Future<void> onPressed()?,
  2. required String label,
  3. OutlinedBorder? shape,
  4. Color? color,
  5. Color? textColor,
  6. double? width,
  7. double? height,
  8. FontWeight? fontWeight,
  9. TextOverflow? overflow,
  10. double? fontSize,
  11. TextAlign? textAlign,
  12. Color? disabledColor,
  13. Key? key,
})

Implementation

TextButton customFlatButton(
    {required Future<void> Function()? onPressed,
    required String label,
    OutlinedBorder? shape,
    Color? color,
    Color? textColor,
    double? width,
    double? height,
    FontWeight? fontWeight,
    TextOverflow? overflow,
    double? fontSize,
    TextAlign? textAlign,
    Color? disabledColor,
    Key? key}) {
  ButtonStyle flatButtonStyle = TextButton.styleFrom(
    minimumSize: Size(width ?? 88, height ?? 36),
    backgroundColor: color,
    disabledBackgroundColor: disabledColor,
    padding: EdgeInsets.symmetric(horizontal: 16.0),
    shape: shape ??
        const RoundedRectangleBorder(
          borderRadius: BorderRadius.all(Radius.circular(2.0)),
        ),
  );
  return TextButton(
    key: key,
    style: flatButtonStyle,
    onPressed: onPressed,
    child: Text(label,
        textAlign: textAlign,
        style: TextStyle(
            color: textColor,
            fontWeight: fontWeight,
            overflow: overflow,
            fontSize: fontSize)),
  );
}