import 'package:flutter/material.dart'; import '../utils/constants.dart'; class CustomButton extends StatelessWidget { final VoidCallback? onPressed; final String text; final bool isLoading; final Color? backgroundColor; final Color? textColor; final double? width; final double? height; final IconData? icon; const CustomButton({ super.key, required this.onPressed, required this.text, this.isLoading = false, this.backgroundColor, this.textColor, this.width, this.height, this.icon, }); @override Widget build(BuildContext context) { return SizedBox( width: width ?? double.infinity, height: height ?? AppSizes.buttonHeight, child: ElevatedButton( onPressed: isLoading ? null : onPressed, style: ElevatedButton.styleFrom( backgroundColor: backgroundColor ?? AppColors.primary, foregroundColor: textColor ?? Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(AppSizes.radiusMedium), ), elevation: 2, ), child: isLoading ? const SizedBox( width: 20, height: 20, child: CircularProgressIndicator( strokeWidth: 2, valueColor: AlwaysStoppedAnimation(Colors.white), ), ) : Row( mainAxisAlignment: MainAxisAlignment.center, children: [ if (icon != null) ...[ Icon(icon, size: 18), const SizedBox(width: AppSizes.paddingSmall), ], Text( text, style: const TextStyle( fontSize: 16, fontWeight: FontWeight.w600, ), ), ], ), ), ); } }