build static method
Builds a complete Material 3 TextTheme for fontFamily.
Pass a Google Fonts family name (for example 'Poppins') and it will be
resolved through the google_fonts package. When useGoogleFonts is
false, the family is applied directly to the type styles.
Implementation
static TextTheme build({
String? fontFamily,
Color? baseColor,
bool useGoogleFonts = true,
double? baseFontSize,
}) {
final String? resolvedFamily;
if (fontFamily == null) {
resolvedFamily = null;
} else if (useGoogleFonts) {
resolvedFamily = GoogleFonts.config.allowRuntimeFetching
? GoogleFonts.getFont(fontFamily).fontFamily
: fontFamily;
} else {
resolvedFamily = fontFamily;
}
TextStyle apply(TextStyle style) => style.copyWith(
fontFamily: resolvedFamily,
color: baseColor,
fontSize: baseFontSize,
);
return TextTheme(
displayLarge: apply(_displayLarge),
displayMedium: apply(_displayMedium),
displaySmall: apply(_displaySmall),
headlineLarge: apply(_headlineLarge),
headlineMedium: apply(_headlineMedium),
headlineSmall: apply(_headlineSmall),
titleLarge: apply(_titleLarge),
titleMedium: apply(_titleMedium),
titleSmall: apply(_titleSmall),
bodyLarge: apply(_bodyLarge),
bodyMedium: apply(_bodyMedium),
bodySmall: apply(_bodySmall),
labelLarge: apply(_labelLarge),
labelMedium: apply(_labelMedium),
labelSmall: apply(_labelSmall),
);
}