taxgilde/lib/consts/comman_button.dart
2026-04-15 12:32:30 +05:30

70 lines
2.0 KiB
Dart

import 'package:flutter/material.dart';
import 'package:taxglide/consts/app_colors.dart';
import 'package:taxglide/consts/app_style.dart';
class CommanButton extends StatelessWidget {
final String text;
final VoidCallback onPressed;
final String? backgroundImage; // optional bg image
final Widget? prefixIcon; // optional prefix icon
const CommanButton({
super.key,
required this.text,
required this.onPressed,
this.backgroundImage,
this.prefixIcon,
});
@override
Widget build(BuildContext context) {
return SizedBox(
width: double.infinity,
height: 57,
child: InkWell(
onTap: onPressed,
borderRadius: BorderRadius.circular(8),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: AppColors.commanbutton, // base color (visible always)
image: backgroundImage != null
? DecorationImage(
image: AssetImage(backgroundImage!),
fit: BoxFit.cover,
// 🔥 THIS MAKES BOTH IMAGE + COLOR VISIBLE
colorFilter: ColorFilter.mode(
AppColors.commanbutton.withOpacity(0.5),
BlendMode.srcATop,
),
)
: null,
),
child: Center(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (prefixIcon != null) ...[
prefixIcon!,
const SizedBox(width: 8),
],
Text(
text,
style: AppTextStyles.semiBold.copyWith(
fontSize: 16,
height: 1.4,
letterSpacing: 0.03 * 16,
color: Colors.white,
),
),
],
),
),
),
),
);
}
}