Typography.material2021 constructor

Typography.material2021({
  1. TargetPlatform? platform = TargetPlatform.android,
  2. ColorScheme colorScheme = const ColorScheme.light(),
  3. TextTheme? black,
  4. TextTheme? white,
  5. TextTheme? englishLike,
  6. TextTheme? dense,
  7. TextTheme? tall,
})

Creates a typography instance using Material Design 3 2021 defaults.

If platform is TargetPlatform.iOS or TargetPlatform.macOS, the default values for black and white are blackCupertino and whiteCupertino respectively. Otherwise they are blackMountainView and whiteMountainView. If platform is null then both black and white must be specified.

The default values for englishLike, dense, and tall are englishLike2021, dense2021, and tall2021.

See also:

Implementation

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
    ),
  );
}