ZeroTypography.fromBrightness constructor

ZeroTypography.fromBrightness({
  1. Brightness? brightness,
  2. Color? color,
  3. String? fontFamily,
})

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 ZeroTypography.fromBrightness({
  Brightness? brightness,
  Color? color,
  String? fontFamily,
}) {
  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 ? ZeroColors.black : ZeroColors.white;

  return ZeroTypography.raw(
    heading1: TextStyle(
      fontWeight: FontWeight.w400,
      fontSize: 56,
      color: color,
      fontFamily: fontFamily,
    ),
    heading2: TextStyle(
      fontWeight: FontWeight.w400,
      fontSize: 48,
      color: color,
      fontFamily: fontFamily,
    ),
    heading3: TextStyle(
      fontWeight: FontWeight.w400,
      fontSize: 40,
      color: color,
      fontFamily: fontFamily,
    ),
    heading4: TextStyle(
      fontWeight: FontWeight.w400,
      fontSize: 30,
      color: color,
      fontFamily: fontFamily,
    ),
    heading5: TextStyle(
      fontWeight: FontWeight.w400,
      fontSize: 24,
      color: color,
      fontFamily: fontFamily,
    ),
    heading6: TextStyle(
      fontWeight: FontWeight.w400,
      fontSize: 20,
      color: color,
      fontFamily: fontFamily,
    ),
    subtitle1: TextStyle(
      fontWeight: FontWeight.w400,
      fontSize: 16,
      color: color,
      fontFamily: fontFamily,
    ),
    subtitle2: TextStyle(
      fontWeight: FontWeight.w400,
      fontSize: 14,
      color: color,
      fontFamily: fontFamily,
    ),
    body1: TextStyle(
      fontWeight: FontWeight.w400,
      fontSize: 16,
      color: color,
      fontFamily: fontFamily,
    ),
    body2: TextStyle(
      fontWeight: FontWeight.w400,
      fontSize: 14,
      color: color,
      fontFamily: fontFamily,
    ),
    button: TextStyle(
      fontWeight: FontWeight.w500,
      fontSize: 14,
      color: color,
      fontFamily: fontFamily,
    ),
    caption: TextStyle(
      fontWeight: FontWeight.w400,
      fontSize: 12,
      color: color,
      fontFamily: fontFamily,
    ),
    overline: TextStyle(
      fontWeight: FontWeight.w400,
      fontSize: 10,
      color: color,
      fontFamily: fontFamily,
    ),
  );
}