check_category_widget.dart 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import 'package:flutter/material.dart';
  2. class CheckCategoryWidget extends StatelessWidget {
  3. final String label;
  4. final String assetName;
  5. final VoidCallback? onTap;
  6. const CheckCategoryWidget({
  7. super.key,
  8. required this.label,
  9. required this.assetName,
  10. this.onTap,
  11. });
  12. @override
  13. Widget build(BuildContext context) {
  14. return Material(
  15. borderRadius: BorderRadius.circular(8),
  16. child: Ink(
  17. child: InkWell(
  18. borderRadius: BorderRadius.circular(8),
  19. onTap: () {
  20. onTap?.call();
  21. },
  22. child: Container(
  23. decoration: BoxDecoration(
  24. borderRadius: BorderRadius.circular(8),
  25. image: DecorationImage(
  26. image:
  27. AssetImage('assets/images/exam/$assetName'), // 替换为你的背景图路径
  28. fit: BoxFit.cover,
  29. ),
  30. ),
  31. width: 260,
  32. height: 290,
  33. padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 14),
  34. alignment: Alignment.topLeft,
  35. child: Text(
  36. label,
  37. style: TextStyle(
  38. fontSize: 28,
  39. color: Colors.grey.shade700,
  40. fontWeight: FontWeight.bold,
  41. ),
  42. ),
  43. ),
  44. ),
  45. ),
  46. );
  47. }
  48. }