Files
CityCards_Customer_Flutter/lib/common_packages/custom_filled_button.dart
2026-04-15 19:06:30 +05:30

72 lines
2.0 KiB
Dart

import 'package:citycards_customer/common_packages/custom_text.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class CustomFilledButton extends StatelessWidget {
final double? width;
final String label;
final bool? showArrow;
final GestureTapCallback? onTap; // ✅ Made nullable
final double? height;
final bool isLoading; // ✅ NEW
const CustomFilledButton({
super.key,
this.width,
required this.onTap,
required this.label,
this.showArrow = false,
this.height,
this.isLoading = false, // ✅ NEW
});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: isLoading ? null : onTap, // ✅ Disabled when loading
child: Container(
height: height ?? 42.h,
width: width ?? 266.w,
decoration: BoxDecoration(
color: isLoading
? Color(0xFFF95F62).withOpacity(0.6) // ✅ Dimmed when loading
: Color(0xFFF95F62),
borderRadius: BorderRadius.circular(38.r),
),
child: Center(
child: isLoading
? SizedBox(
height: 20.sp,
width: 20.sp,
child: CircularProgressIndicator(
color: Colors.white,
strokeWidth: 2,
),
)
: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Flexible(
child: CustomText(
text: label,
color: Colors.white,
size: 16.sp,
weight: FontWeight.w500,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
if (showArrow!) SizedBox(width: 8),
if (showArrow!)
Icon(
Icons.arrow_forward_ios_rounded,
size: 18.sp,
color: Colors.white,
),
],
),
),
),
);
}
}