Skip to content

Instantly share code, notes, and snippets.

@fredgrott
Created November 9, 2025 13:38
Show Gist options
  • Select an option

  • Save fredgrott/cd82ca0022ec6586dfbe693a8315252c to your computer and use it in GitHub Desktop.

Select an option

Save fredgrott/cd82ca0022ec6586dfbe693a8315252c to your computer and use it in GitHub Desktop.
SDK typograhy calls
factory Typography.material2021({
TargetPlatform? platform = TargetPlatform.android,
ColorScheme colorScheme = const ColorScheme.light(),
TextTheme? black,
TextTheme? white,
TextTheme? englishLike,
TextTheme? dense,
TextTheme? tall,
}) {
assert(platform != null || (black != null && white != null));
final Typography base = Typography._withPlatform(
platform,
black,
white,
englishLike ?? englishLike2021,
dense ?? dense2021,
tall ?? tall2021,
);
// Ensure they are all uniformly dark or light, with
// no color variation based on style as it was in previous
// versions of Material Design.
final Color dark = colorScheme.brightness == Brightness.light
? colorScheme.onSurface
: colorScheme.surface;
final Color light = colorScheme.brightness == Brightness.light
? colorScheme.surface
: colorScheme.onSurface;
return base.copyWith(
black: base.black.apply(displayColor: dark, bodyColor: dark, decorationColor: dark),
white: base.white.apply(displayColor: light, bodyColor: light, decorationColor: light),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment