game/lib/widgets/common/custom_button_widget.dart

55 lines
1.3 KiB
Dart

import 'package:flutter/material.dart';
class CustomButtonWidget extends StatelessWidget {
final Widget child;
final VoidCallback? onTap;
final String imagePath;
final double? width;
final double? height;
final EdgeInsetsGeometry padding;
final Color? backgroundColor;
const CustomButtonWidget({
super.key,
required this.child,
this.onTap,
this.imagePath = 'assets/images/icons/borders/border_000.png',
this.width,
this.height,
this.padding = EdgeInsets.zero,
this.backgroundColor,
});
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
behavior: HitTestBehavior.opaque,
child: SizedBox(
width: width,
height: height,
child: Stack(
children: [
// Background Color
if (backgroundColor != null)
Positioned.fill(child: Container(color: backgroundColor)),
// Background Image (Border)
Positioned.fill(
child: Image.asset(
imagePath,
fit: BoxFit.fill,
filterQuality: FilterQuality.high,
),
),
// Content
Padding(
padding: padding,
child: Center(child: child),
),
],
),
),
);
}
}