defaultHeadingStyles function

Map<HeadingTag, TextStyle> defaultHeadingStyles(
  1. TextStyle baseTextStyle
)

The heading styles the default theme applies, by tag.

Exposed because a toolbar usually wants to preview them, and duplicating the scale in application code is how the two drift apart.

Implementation

Map<HeadingTag, TextStyle> defaultHeadingStyles(TextStyle baseTextStyle) {
  final size = baseTextStyle.fontSize ?? 16;
  TextStyle at(double scale, FontWeight weight) => baseTextStyle.copyWith(
    fontSize: size * scale,
    fontWeight: weight,
    height: 1.25,
  );
  return {
    HeadingTag.h1: at(2, FontWeight.w700),
    HeadingTag.h2: at(1.6, FontWeight.w700),
    HeadingTag.h3: at(1.35, FontWeight.w600),
    HeadingTag.h4: at(1.15, FontWeight.w600),
    HeadingTag.h5: at(1, FontWeight.w600),
    HeadingTag.h6: at(0.9, FontWeight.w600),
  };
}