import 'package:flutter/material.dart'; /// 「标签 + 大数字 +(可选)单位」的组合,学习页与账户页共用。 class StatBlock extends StatelessWidget { const StatBlock({ required this.label, required this.value, this.unit, super.key, }); final String label; final String value; final String? unit; @override Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); final ColorScheme colors = theme.colorScheme; final String? unit = this.unit; return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( label, style: theme.textTheme.bodyMedium?.copyWith( color: colors.onSurfaceVariant, ), ), const SizedBox(height: 2), Row( crossAxisAlignment: CrossAxisAlignment.baseline, textBaseline: TextBaseline.alphabetic, children: [ Flexible( child: Text( value, maxLines: 1, overflow: TextOverflow.ellipsis, style: theme.textTheme.displaySmall?.copyWith( fontWeight: FontWeight.w700, height: 1.1, ), ), ), if (unit != null) ...[ const SizedBox(width: 6), Text( unit, style: theme.textTheme.bodySmall?.copyWith( color: colors.onSurfaceVariant, ), ), ], ], ), ], ); } }