Typography.fromBrightness constructor

Typography.fromBrightness({
  1. Brightness? brightness,
  2. Color? color,
})

The default typography according to a brightness or color.

If color is null, Colors.black is used if brightness is light, otherwise Colors.white is used. If it's not null, color will be used.

Implementation

factory Typography.fromBrightness({
  Brightness? brightness,
  Color? color,
}) {
  assert(
    brightness != null || color != null,
    'Either brightness or color must be provided',
  );
  // If color is null, brightness will not be null
  color ??=
      brightness == Brightness.light ? const Color(0xE4000000) : Colors.white;
  return Typography.raw(
    display: TextStyle(
      fontSize: 68,
      color: color,
      fontWeight: FontWeight.w600,
    ),
    titleLarge: TextStyle(
      fontSize: 40,
      color: color,
      fontWeight: FontWeight.w600,
    ),
    title: TextStyle(
      fontSize: 28,
      color: color,
      fontWeight: FontWeight.w600,
    ),
    subtitle: TextStyle(
      fontSize: 20,
      color: color,
      fontWeight: FontWeight.w600,
    ),
    bodyLarge: TextStyle(
      fontSize: 18,
      color: color,
      fontWeight: FontWeight.normal,
    ),
    bodyStrong: TextStyle(
      fontSize: 14,
      color: color,
      fontWeight: FontWeight.w600,
    ),
    body: TextStyle(
      fontSize: 14,
      color: color,
      fontWeight: FontWeight.normal,
    ),
    caption: TextStyle(
      fontSize: 12,
      color: color,
      fontWeight: FontWeight.normal,
    ),
  );
}