import 'package:flutter/material.dart'; class RoundedBtn extends StatelessWidget { static const btnRadius = Radius.circular(90.0); final IconData icon; final String text; final Color backColor; final Color fontColor; final TextStyle textStyle; final VoidCallback onPressed; const RoundedBtn({ required this.icon, required this.text, required this.onPressed, required this.backColor, this.textStyle = const TextStyle(fontSize: 20.0, color: Colors.white), this.fontColor = Colors.white, }); factory RoundedBtn.nav({ required IconData icon, required String text, required BuildContext context, required String route, required Color backColor, TextStyle textStyle = const TextStyle(fontSize: 20.0, color: Colors.white), Color fontColor = Colors.white, }) { return RoundedBtn( icon: icon, text: text, onPressed: () { Navigator.pushNamed(context, route); }, backColor: backColor, textStyle: textStyle, fontColor: fontColor, ); } @override Widget build(BuildContext context) { return SizedBox( child: ElevatedButton( onPressed: onPressed, style: ElevatedButton.styleFrom( backgroundColor: backColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.all(btnRadius), ), ), child: Padding( padding: const EdgeInsets.all(10.0), child: Row( mainAxisSize: MainAxisSize.min, children: [ Icon(icon, size: 32.0, color: fontColor), const SizedBox(width: 10.0), Text(text, style: textStyle), ], ), ), ), ); } }