semanticHeading method

DVModifier semanticHeading(
  1. int level
)

Mark this as a heading at level.

A page's structure is carried by its headings: a screen reader user moves between them, and a crawler reads the document outline from them. Without this there was no way to say a piece of text was one, so the semantics tree contained no headings at all and the generated static HTML had nothing to build an outline from.

One to six, because that is what HTML has and what every platform's accessibility layer can express. A seventh would produce a semantics node nothing can represent and an <h7> that does not exist.

Implementation

DVModifier semanticHeading(int level) {
  if (level < 1 || level > 6) {
    throw ArgumentError.value(
      level,
      'level',
      'A heading level is 1 to 6.',
    );
  }
  return _copyWith(semanticHeadingValue: level);
}