typography static method
Implementation
static String typography(DesignTokens tokens) {
final r = tokens.recipe;
final weight = r.boldHeadlines ? 'FontWeight.w700' : 'FontWeight.w500';
return '''
import 'package:flutter/material.dart';
import 'app_colors.dart';
/// Typography scale. Prefer this over hard-coded font sizes.
class AppTypography {
AppTypography._();
static const TextStyle display = TextStyle(
fontSize: ${r.displaySize},
fontWeight: $weight,
color: AppColors.textPrimary,
height: 1.2,
);
static const TextStyle headline = TextStyle(
fontSize: ${r.headlineSize},
fontWeight: $weight,
color: AppColors.textPrimary,
height: 1.25,
);
static const TextStyle title = TextStyle(
fontSize: ${r.titleSize},
fontWeight: FontWeight.w600,
color: AppColors.textPrimary,
height: 1.3,
);
static const TextStyle body = TextStyle(
fontSize: ${r.bodySize},
fontWeight: FontWeight.w400,
color: AppColors.textPrimary,
height: 1.5,
);
static const TextStyle bodyBold = TextStyle(
fontSize: ${r.bodySize},
fontWeight: FontWeight.w600,
color: AppColors.textPrimary,
height: 1.5,
);
static const TextStyle label = TextStyle(
fontSize: ${r.labelSize},
fontWeight: FontWeight.w600,
letterSpacing: 0.2,
color: AppColors.textPrimary,
height: 1.3,
);
static const TextStyle caption = TextStyle(
fontSize: ${r.captionSize},
fontWeight: FontWeight.w400,
color: AppColors.textSecondary,
height: 1.4,
);
static const TextStyle button = TextStyle(
fontSize: ${r.labelSize},
fontWeight: FontWeight.w600,
letterSpacing: 0.3,
);
}
/// Legacy alias used by older generated screens.
class AppTextStyles {
AppTextStyles._();
static const TextStyle h1 = AppTypography.display;
static const TextStyle h2 = AppTypography.headline;
static const TextStyle h3 = AppTypography.title;
static const TextStyle body = AppTypography.body;
static const TextStyle bodyBold = AppTypography.bodyBold;
static const TextStyle caption = AppTypography.caption;
static const TextStyle button = AppTypography.button;
}
''';
}