getTextTheme static method Null safety

TextTheme getTextTheme(
  1. String fontFamily,
  2. [TextTheme? textTheme]
)

Retrieve a text theme by its font family name.

Applies the given font family from Google Fonts to the given textTheme and returns the resulting textTheme.

Note: fontFamily is case-sensitive.

Parameter fontFamily must not be null. Throws if no font by name fontFamily exists.

Implementation

static TextTheme getTextTheme(String fontFamily, [TextTheme? textTheme]) {
  final fonts = _asMapOfTextThemes();
  if (!fonts.containsKey(fontFamily)) {
    throw Exception("No font family by name '$fontFamily' was found.");
  }
  return fonts[fontFamily]!(textTheme);
}