import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; /// A button that shows a busy indicator in place of title class AmanIconButton extends StatefulWidget { final bool busy; final String title; final Function onPressed; final bool enabled; final Color mainColor; final IconData icon; const AmanIconButton( { required this.title, this.busy = false, required this.onPressed, this.enabled = true, required this.mainColor, required this.icon }); @override _AmanIconButtonState createState() => _AmanIconButtonState(); } class _AmanIconButtonState extends State { @override Widget build(BuildContext context) { return GestureDetector( child: InkWell( borderRadius: BorderRadius.circular(15), onTap: widget.busy ? () {} : () => widget.onPressed(), child: Container( //height: 75, width: 120, alignment: Alignment.center, padding: EdgeInsets.symmetric( //horizontal: 25, vertical: 15), decoration: BoxDecoration( //color: widget.enabled ? ( whiteColor ) : blueColorLigth, borderRadius: BorderRadius.circular(50), //boxShadow: [buttonShadowBox], ), child: Column( children: [ (!widget.busy ? Icon( widget.icon, color: widget.mainColor, size: 36, ) : CircularProgressIndicator( strokeWidth: 3, valueColor: AlwaysStoppedAnimation(widget.mainColor))), AutoSizeText(widget.title, overflow: TextOverflow.fade, maxLines: 2, style: TextStyle(color: widget.mainColor, fontSize: 14, fontWeight: FontWeight.w800, ), textAlign: TextAlign.center,) ], ), ), ), ); } }