getFont method
- String fontFamily,
- {TextStyle textStyle,
- Color color,
- Color backgroundColor,
- double fontSize,
- FontWeight fontWeight,
- FontStyle fontStyle,
- double letterSpacing,
- double wordSpacing,
- TextBaseline textBaseline,
- double height,
- Locale locale,
- Paint foreground,
- Paint background,
- List<
Shadow> shadows, - List<
FontFeature> fontFeatures, - TextDecoration decoration,
- Color decorationColor,
- TextDecorationStyle decorationStyle,
- double decorationThickness}
Retrieve a font by family name.
Applies the given font family from Google Fonts to the given textStyle
and returns the resulting TextStyle.
Note: fontFamily
is case-sensitive.
Parameter fontFamily
must not be null
. Throws if no font by name
fontFamily
exists.
Implementation
static TextStyle getFont(
String fontFamily, {
TextStyle textStyle,
Color color,
Color backgroundColor,
double fontSize,
FontWeight fontWeight,
FontStyle fontStyle,
double letterSpacing,
double wordSpacing,
TextBaseline textBaseline,
double height,
Locale locale,
Paint foreground,
Paint background,
List<ui.Shadow> shadows,
List<ui.FontFeature> fontFeatures,
TextDecoration decoration,
Color decorationColor,
TextDecorationStyle decorationStyle,
double decorationThickness,
}) {
assert(fontFamily != null);
final fonts = GoogleFonts.asMap();
if (!fonts.containsKey(fontFamily)) {
throw Exception("No font family by name '$fontFamily' was found.");
}
return fonts[fontFamily](
textStyle: textStyle,
color: color,
backgroundColor: backgroundColor,
fontSize: fontSize,
fontWeight: fontWeight,
fontStyle: fontStyle,
letterSpacing: letterSpacing,
wordSpacing: wordSpacing,
textBaseline: textBaseline,
height: height,
locale: locale,
foreground: foreground,
background: background,
shadows: shadows,
fontFeatures: fontFeatures,
decoration: decoration,
decorationColor: decorationColor,
decorationStyle: decorationStyle,
decorationThickness: decorationThickness,
);
}