123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- import 'package:flutter/material.dart';
- import 'package:vitalapp/consts/styles.dart';
- /// 检查小卡片
- class ExamCard extends StatelessWidget {
- const ExamCard({
- super.key,
- this.title,
- required this.content,
- this.clickCard,
- this.titleText,
- this.topPadding = 20,
- });
- final String? title;
- final Widget content;
- final Widget? titleText;
- final Function? clickCard;
- final double topPadding;
- @override
- Widget build(BuildContext context) {
- return Card(
- elevation: 6,
- shape: RoundedRectangleBorder(
- borderRadius: GlobalStyles.borderRadius,
- ),
- child: Material(
- color: Colors.white,
- borderRadius: GlobalStyles.borderRadius,
- child: InkWell(
- borderRadius: GlobalStyles.borderRadius,
- onTap: clickCard != null ? () => clickCard!.call() : null,
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- _buildTitle(),
- content,
- ],
- ),
- ),
- ),
- );
- }
- Widget _buildTitle() {
- Widget titleContent = const SizedBox();
- if (title?.isNotEmpty ?? false) {
- titleContent = Text(
- title!,
- style: const TextStyle(fontSize: 25),
- );
- }
- return titleText ??
- Container(
- padding: EdgeInsets.only(
- top: topPadding,
- left: 30,
- bottom: 15,
- ),
- child: titleContent,
- );
- }
- }
|