import 'package:flutter/material.dart'; class FilledButtonComponent extends StatelessWidget { const FilledButtonComponent({ Key? key, this.width, required this.label, required this.onPressed, required this.inProcess, this.icon, this.alignmentIcon, this.color, }) : super(key: key); final double? width; final String label; final Function()? onPressed; final IconData? icon; final AlignmentGeometry? alignmentIcon; final bool inProcess; final Color? color; @override Widget build(BuildContext context) { return SizedBox( width: width ?? MediaQuery.of(context).size.width * 0.9, height: 70, child: ElevatedButton( style: ButtonStyle( foregroundColor: MaterialStateProperty.all(Colors.white), backgroundColor: MaterialStateProperty.all(onPressed == null ? Colors.grey : color ?? Theme.of(context).highlightColor), shape: MaterialStateProperty.all( RoundedRectangleBorder( borderRadius: BorderRadius.circular(20), side: BorderSide(color: onPressed == null ? Colors.grey : Theme.of(context).highlightColor), ), ), elevation: MaterialStateProperty.all(8)), child: inProcess ? const CircularProgressIndicator( color: Colors.white, ) : Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Text(label, textScaleFactor: 1.0, style: const TextStyle(fontSize: 16, fontWeight: FontWeight.w700), textAlign: TextAlign.center), if (icon != null) Container( padding: const EdgeInsets.only(left: 10), alignment: alignmentIcon, child: Icon(icon), ), ], ), onPressed: onPressed, ), ); } }