import 'package:flutter/material.dart'; class LoadingButton extends StatelessWidget { final bool loading; final String label; final VoidCallback? onPressed; final Color? backgroundColor; const LoadingButton({ super.key, required this.loading, required this.label, this.onPressed, this.backgroundColor, }); @override Widget build(BuildContext context) => ElevatedButton( onPressed: loading ? null : onPressed, style: backgroundColor != null ? ElevatedButton.styleFrom(backgroundColor: backgroundColor) : null, child: loading ? const SizedBox( width: 20, height: 20, child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white), ) : Text(label), ); }