Files
tuiche/lib/component/tool/ClickableContainer.dart
2025-05-15 13:57:42 +08:00

45 lines
1.1 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 Material(
color: Colors.transparent,
child: Ink(
decoration: BoxDecoration(
color: backgroundColor,
borderRadius: BorderRadius.circular(borderRadius),
),
child: InkWell(
borderRadius: BorderRadius.circular(borderRadius),
onTap: onTap,
splashColor: highlightColor == Colors.transparent
? Colors.transparent
: highlightColor.withOpacity(0.5),
child: Padding(
padding: padding,
child: child,
),
),
),
);
}
}