textButton method

Widget textButton({
  1. required void onPressed()?,
  2. required String text,
  3. double? elevation,
  4. EdgeInsetsGeometry? padding,
  5. Color? backgroundColor,
  6. Color? overlayColor,
  7. double? fontSize,
  8. TextStyle? style,
  9. double? borderRadius,
  10. Widget? child,
})

customized text button with default option

Implementation

Widget textButton({
  required void Function()? onPressed,
  required String text,
  double? elevation,
  EdgeInsetsGeometry? padding,
  Color? backgroundColor,
  Color? overlayColor,
  double? fontSize,
  TextStyle? style,
  double? borderRadius,
  Widget? child,
}) {
  return ElevatedButton(
    onPressed: onPressed,
    style: ButtonStyle(
      backgroundColor:
          MaterialStateProperty.all(backgroundColor ?? themeColor),
      surfaceTintColor: MaterialStateProperty.all(primaryColor),
      foregroundColor: MaterialStateProperty.all(Colors.transparent),
      padding: MaterialStateProperty.all(padding ??
          (kIsWeb || Platform.isWindows
              ? const EdgeInsets.only(
                  left: 20, right: 20, bottom: 15, top: 10)
              : const EdgeInsets.symmetric(horizontal: 20, vertical: 8))),
      elevation: MaterialStateProperty.all(elevation ?? 4),
      shape: MaterialStateProperty.all(
        RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(borderRadius ?? 8),
        ),
      ),
      overlayColor: MaterialStateProperty.all(
          overlayColor ?? Colors.black.withOpacity(0.04)),
    ),
    child: child ??
        Text(
          text,
          style: style ??
              TextStyle(
                  fontSize: fontSize ?? 18,
                  fontWeight: FontWeight.bold,
                  color: primaryColor),
        ),
  );
}