textStyle method
A finished text style of the theme: one of the 15 by name
(titleLarge, title-large) or code, with what the properties set
over the platform's font and the palette's on-surface color. It has
the size the properties give it and no other: localizedTextStyle
adds the size of the type scale. Throws an ArgumentError for
another name.
Implementation
TextStyle textStyle(String style) {
final key = ThemeValues.canonical(style);
if (key == 'code') {
// Falls back to the theme's own font where the monospaced one is
// missing (`monospace` is not a family on every platform).
return code
.applyTo(_named('bodymedium'))
.copyWith(
fontFamily: code.fontFamily,
fontFamilyFallback: [?fontFamily, ...?fontFamilyFallback],
);
}
if (!textStyleNames.contains(key)) {
throw ArgumentError.value(style, 'style', 'a TextTheme style or code');
}
return _named(key);
}