exam_radio_and_select.dart 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import 'package:flutter/material.dart';
  2. import 'package:vitalapp/consts/styles.dart';
  3. /// 检查小卡片
  4. class ExamCardRadioSelect extends StatelessWidget {
  5. const ExamCardRadioSelect({
  6. super.key,
  7. this.title,
  8. required this.content,
  9. this.clickCard,
  10. this.titleText,
  11. this.topPadding = 20,
  12. this.required,
  13. });
  14. final String? title;
  15. final Widget content;
  16. final Widget? titleText;
  17. final Function? clickCard;
  18. final double topPadding;
  19. final bool? required;
  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: Column(
  34. crossAxisAlignment: CrossAxisAlignment.start,
  35. mainAxisAlignment: MainAxisAlignment.center,
  36. children: [
  37. _buildTitle(),
  38. content,
  39. ],
  40. ),
  41. ),
  42. ),
  43. );
  44. }
  45. Widget _buildTitle() {
  46. Widget titleContent = const SizedBox();
  47. if (title?.isNotEmpty ?? false) {
  48. titleContent = RichText(
  49. text: TextSpan(
  50. text: '',
  51. children: [
  52. if (required ?? false)
  53. TextSpan(
  54. text: "* ",
  55. style: const TextStyle(color: Colors.red, fontSize: 35),
  56. ),
  57. TextSpan(
  58. text: title ?? '',
  59. style: TextStyle(
  60. fontSize: 24,
  61. color: Colors.black,
  62. fontFamily: "NotoSansSC",
  63. fontFamilyFallback: const ["NotoSansSC"],
  64. ),
  65. ),
  66. ],
  67. ),
  68. );
  69. }
  70. return titleText ??
  71. Container(
  72. padding: EdgeInsets.only(
  73. top: topPadding,
  74. left: 30,
  75. bottom: 15,
  76. ),
  77. child: titleContent,
  78. );
  79. }
  80. }