Button constructor

Button({
  1. Key? key,
  2. required BuildContext context,
  3. required String title,
  4. required void action(),
  5. Color? color = const Color.fromRGBO(255, 165, 40, 1),
  6. bool isLoading = false,
})

Implementation

Button({
  super.key,
  required this.context,
  required this.title,
  required this.action,
  this.color = const Color.fromRGBO(255, 165, 40, 1),
  this.isLoading = false
}) : super(
  onTap: (){
    if(!isLoading){
      action();
    }
  },
  child: Container(
      padding:  const EdgeInsets.all(15),
      width: Utils.width(context),
      decoration: BoxDecoration(
          color: isLoading ? Colors.grey : color,
          borderRadius: BorderRadius.circular(5)
      ),
      child: Center(
        child: (isLoading) ?
        const SizedBox(
            height: 15,
            width: 15,
            child: CircularProgressIndicator(
              strokeWidth: 3,
              color: Colors.white,
            )
        ) :
        Text(
          title,
          style: const TextStyle(
              color: Colors.white,
              fontWeight: FontWeight.w700
          ),
        ),
      )
  ),
);