46 lines
1.2 KiB
Dart
46 lines
1.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class ClickableContainer extends StatelessWidget {
|
|
final Color backgroundColor;
|
|
final Color highlightColor;
|
|
final EdgeInsetsGeometry padding;
|
|
final VoidCallback onTap;
|
|
final Widget child;
|
|
final double borderRadius;
|
|
|
|
const ClickableContainer({
|
|
Key? key,
|
|
required this.backgroundColor,
|
|
required this.highlightColor,
|
|
required this.padding,
|
|
required this.onTap,
|
|
required this.child,
|
|
this.borderRadius = 0,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Theme(
|
|
data: Theme.of(context).copyWith(splashFactory: InkRipple.splashFactory),
|
|
child: Material(
|
|
color: Colors.transparent,
|
|
child: Ink(
|
|
decoration: BoxDecoration(
|
|
color: backgroundColor,
|
|
borderRadius: BorderRadius.circular(borderRadius),
|
|
),
|
|
child: InkWell(
|
|
borderRadius: BorderRadius.circular(borderRadius),
|
|
onTap: onTap,
|
|
splashColor: highlightColor.withOpacity(0.2),
|
|
child: Padding(
|
|
padding: padding,
|
|
child: child,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|