app/lib/view/widgets/custom_button.dart
2021-08-16 17:42:41 +07:00

40 lines
No EOL
1,004 B
Dart

import 'package:flutter/material.dart';
class CustomButton extends StatefulWidget {
const CustomButton({Key? key, required this.name, required this.size}) : super(key: key);
final String name;
final double size;
@override
_CustomButtonState createState() => _CustomButtonState();
}
class _CustomButtonState extends State<CustomButton> {
bool isTap = false;
@override
Widget build(BuildContext context) {
return InkWell(
onTap: () {
setState(() {
isTap = true;
});
},
onTapDown: (x) {
setState(() {
isTap = false;
});
},
child: AnimatedContainer(
duration: const Duration(milliseconds: 150),
width: isTap ? widget.size - 10 : widget.size,
height: isTap ? widget.size - 10 : widget.size,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/buttons/${widget.name}.png'),
)
),
),
);
}
}