| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- import 'package:flutter/material.dart';
- class ImageButton extends StatelessWidget {
- final Size buttonSize;
- final String image;
- final Size imageSize;
- final Color bgColor;
- final double borderRadius;
- final Color borderColor;
- final double borderWidth;
- final VoidCallback onTap;
- ImageButton({
- required Size buttonSize,
- required this.image,
- Size? imageSize,
- Color bgColor = Colors.white,
- this.borderRadius = 5,
- Color? borderColor,
- this.borderWidth = 1,
- required this.onTap,
- })
- : buttonSize = buttonSize,
- imageSize = imageSize ?? buttonSize,
- bgColor = bgColor,
- borderColor = borderColor ?? bgColor
- ;
- @override
- Widget build(BuildContext context) {
- return GestureDetector(
- onTap: onTap,
- child: Container(
- width: buttonSize.width,
- height: buttonSize.height,
- decoration: BoxDecoration(
- color: bgColor,
- shape: BoxShape.rectangle,
- borderRadius: BorderRadius.all(Radius.circular(borderRadius)),
- border: Border.all(color: borderColor),
- ),
- child: Center(
- child: Image.asset(
- image,
- width: imageSize.width,
- height: imageSize.height,
- ),
- ),
- ),
- );
- }
- }
|