exam_card.dart 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. this.isSelect = false,
  13. });
  14. final String? title;
  15. final Widget content;
  16. final Widget? titleText;
  17. final Function? clickCard;
  18. final double topPadding;
  19. final bool isSelect;
  20. @override
  21. Widget build(BuildContext context) {
  22. return Card(
  23. elevation: 6,
  24. shape: RoundedRectangleBorder(
  25. borderRadius: GlobalStyles.borderRadius,
  26. ),
  27. child: Material(
  28. color: Colors.white,
  29. borderRadius: GlobalStyles.borderRadius,
  30. child: InkWell(
  31. borderRadius: GlobalStyles.borderRadius,
  32. onTap: clickCard != null ? () => clickCard!.call() : null,
  33. child: _buildTitle(),
  34. ),
  35. ),
  36. );
  37. }
  38. Widget _buildTitle() {
  39. Widget titleContent = const SizedBox();
  40. if (title?.isNotEmpty ?? false) {
  41. titleContent = Text(
  42. title!,
  43. style: const TextStyle(fontSize: 26),
  44. );
  45. }
  46. return titleText ??
  47. Container(
  48. padding: EdgeInsets.only(
  49. top: topPadding,
  50. left: 30,
  51. bottom: 15,
  52. ),
  53. child: Row(
  54. mainAxisAlignment: MainAxisAlignment.center,
  55. crossAxisAlignment: CrossAxisAlignment.center,
  56. children: [
  57. titleContent,
  58. Expanded(child: content),
  59. ],
  60. ),
  61. );
  62. }
  63. }