exam_card.dart 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import 'package:flutter/material.dart';
  2. import 'package:vitalapp/consts/styles.dart';
  3. /// 检查小卡片
  4. class ExamCard extends StatelessWidget {
  5. const ExamCard({
  6. super.key,
  7. this.title,
  8. required this.content,
  9. this.clickCard,
  10. this.titleText,
  11. this.topPadding = 20,
  12. });
  13. final String? title;
  14. final Widget content;
  15. final Widget? titleText;
  16. final Function? clickCard;
  17. final double topPadding;
  18. @override
  19. Widget build(BuildContext context) {
  20. return Card(
  21. elevation: 6,
  22. shape: RoundedRectangleBorder(
  23. borderRadius: GlobalStyles.borderRadius,
  24. ),
  25. child: Material(
  26. color: Colors.white,
  27. borderRadius: GlobalStyles.borderRadius,
  28. child: InkWell(
  29. borderRadius: GlobalStyles.borderRadius,
  30. onTap: clickCard != null ? () => clickCard!.call() : null,
  31. child: Column(
  32. crossAxisAlignment: CrossAxisAlignment.start,
  33. mainAxisAlignment: MainAxisAlignment.center,
  34. children: [
  35. _buildTitle(),
  36. content,
  37. ],
  38. ),
  39. ),
  40. ),
  41. );
  42. }
  43. Widget _buildTitle() {
  44. Widget titleContent = const SizedBox();
  45. if (title?.isNotEmpty ?? false) {
  46. titleContent = Text(
  47. title!,
  48. style: const TextStyle(fontSize: 25),
  49. );
  50. }
  51. return titleText ??
  52. Container(
  53. padding: EdgeInsets.only(
  54. top: topPadding,
  55. left: 30,
  56. bottom: 15,
  57. ),
  58. child: titleContent,
  59. );
  60. }
  61. }