Files

62 lines
1.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:google_fonts/google_fonts.dart';
import '../constants/app_colors.dart';
class CustomButton extends StatelessWidget {
final String text;
final VoidCallback? onPressed;
final bool isLoading;
final Color? backgroundColor;
final Color? textColor;
final double height;
final double borderRadius;
const CustomButton({
super.key,
required this.text,
this.onPressed,
this.isLoading = false,
this.backgroundColor,
this.textColor,
this.height = 56,
this.borderRadius = 16,
});
@override
Widget build(BuildContext context) {
return SizedBox(
width: double.infinity,
height: height.h,
child: ElevatedButton(
onPressed: isLoading ? null : onPressed,
style: ElevatedButton.styleFrom(
backgroundColor: backgroundColor ?? AppColors.primaryRed,
disabledBackgroundColor: (backgroundColor ?? AppColors.primaryRed).withOpacity(0.4),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(borderRadius.r),
),
elevation: 0,
),
child: isLoading
? SizedBox(
height: 24.h,
width: 24.w,
child: const CircularProgressIndicator(
color: Colors.white,
strokeWidth: 2,
),
)
: Text(
text,
style: GoogleFonts.poppins(
color: textColor ?? Colors.white,
fontSize: 18.sp,
fontWeight: FontWeight.w600,
),
),
),
);
}
}