import 'package:flutter/material.dart'; enum ButtonType { primary, secondary } class EasyButton extends StatelessWidget { const EasyButton({ Key? key, required this.text, required this.onPressed, this.type = ButtonType.primary, this.padding, this.height = 48, this.minWidth = double.infinity, this.borderSide, this.textColor, this.color, this.fontWeight, this.borderRadius = 6, }) : super(key: key); final String text; final VoidCallback? onPressed; final ButtonType type; final EdgeInsets? padding; final double height; final double minWidth; final BorderSide? borderSide; final Color? textColor; final Color? color; final FontWeight? fontWeight; final double borderRadius; @override Widget build(BuildContext context) { return Container( color: Colors.transparent, padding: padding, child: TextButton( style: ButtonStyle( backgroundColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.disabled)) { return Colors.grey.withOpacity(0.5); } return color ?? (type == ButtonType.secondary ? Colors.white : Colors.blue); }), foregroundColor: MaterialStateProperty.resolveWith((Set states) { if (states.contains(MaterialState.disabled)) { return Colors.grey.withOpacity(0.1); } return color ?? (type == ButtonType.secondary ? Colors.white : Colors.blue); }), minimumSize: MaterialStateProperty.all(Size(minWidth, height)), shape: MaterialStateProperty.all( RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(borderRadius)), side: type == ButtonType.secondary ? borderSide ?? BorderSide(color: Colors.grey.withOpacity(0.9)) : BorderSide.none, ), ), ), onPressed: onPressed, child: Text( text, style: TextStyle( fontWeight: fontWeight ?? FontWeight.normal, fontSize: 20, color: textColor ?? (type == ButtonType.secondary ? Colors.grey : Colors.white)), ), ), ); } }