M3ETypography.defaultFor constructor
M3ETypography.defaultFor(
- Brightness brightness, {
- String? brandFontFamily,
- String? plainFontFamily,
- TextTheme? baseOverride,
Build default M3E typography from M3.
brandFontFamily is typically your UI/brand face (e.g., Roboto Flex).
plainFontFamily is typically your reading face (e.g., Roboto Serif).
If you pass neither, you’ll get pure M3 defaults (no family swap),
but still keep the M3E emphasized set for optional use.
Implementation
factory M3ETypography.defaultFor(
Brightness brightness, {
String? brandFontFamily,
String? plainFontFamily,
TextTheme? baseOverride,
}) {
// 1) Start from Material 3 baseline type.
final m3 = Typography.material2021();
final TextTheme m3Base =
baseOverride ?? (brightness == Brightness.dark ? m3.white : m3.black);
// 2) Optionally map brand/plain families to role groups (M3E guidance).
final TextTheme baseWithFamilies = _applyFamilies(
m3Base,
brand: brandFontFamily,
plain: plainFontFamily,
);
// 3) Provide emphasized deltas (weights/tracking).
return M3ETypography(
base: baseWithFamilies,
emphasized: M3EEmphasized.forBrightness(brightness),
);
}