check_category_widget.dart 1.4 KB

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