getTitleStyle static method

TextStyle getTitleStyle(
  1. BuildContext context,
  2. Variant? variant,
  3. TitleType? titleType
)

Implementation

static TextStyle getTitleStyle(
    BuildContext context, Variant? variant, TitleType? titleType) {
  final TextTheme textTheme = Theme.of(context).textTheme;
  final bool isSemiBold = variant == Variant.semiBold;

  switch (titleType) {
    case TitleType.h1:
      return textTheme.headlineLarge!.copyWith(
        fontWeight: isSemiBold ? FontWeight.w600 : FontWeight.w500,
      );
    case TitleType.h2:
      return textTheme.headlineMedium!.copyWith(
        fontWeight: isSemiBold ? FontWeight.w600 : FontWeight.w500,
      );
    case TitleType.h3:
      return textTheme.headlineSmall!.copyWith(
        fontWeight: isSemiBold ? FontWeight.w600 : FontWeight.w500,
      );
    case TitleType.h4:
      return textTheme.titleLarge!.copyWith(
        fontWeight: isSemiBold ? FontWeight.w600 : FontWeight.w500,
      );
    case TitleType.h5:
      return textTheme.titleMedium!.copyWith(
        fontWeight: isSemiBold ? FontWeight.w600 : FontWeight.w500,
      );
    case TitleType.h6:
      return textTheme.titleSmall!.copyWith(
        fontWeight: isSemiBold ? FontWeight.w600 : FontWeight.w500,
      );
    default:
      return textTheme.titleLarge!;
  }
}