Skip to main content

StrutStyle

Defines the strut used for vertical text layout.

A strut sets the minimum line height relative to the baseline and applies to every line in the paragraph. It is useful when text may vary in script or font metrics but should still keep a predictable vertical rhythm.

Properties

  • font_family - See Text.font_family.
  • force_strut_height - Whether the strut height should be forced.
  • height - The minimum height of the strut, as a multiple of size.
  • italic - Whether to use italic typeface.
  • leading - The amount of additional space to place between lines when rendering text.
  • size - The size of text (in logical pixels) to use when getting metrics from the font.
  • weight - The typeface thickness to use when calculating the strut.

Methods

  • copy - Returns a copy of this object with the specified properties overridden.

Properties​

font_familyclass-attributeinstance-attribute​

font_family: str | None = None

See Text.font_family.

force_strut_heightclass-attributeinstance-attribute​

force_strut_height: bool | None = None

Whether the strut height should be forced.

Defaults to False.

heightclass-attributeinstance-attribute​

height: Number | None = None

The minimum height of the strut, as a multiple of size.

See detailed explanation here: https://api.flutter.dev/flutter/painting/StrutStyle/height.html

italicclass-attributeinstance-attribute​

italic: bool = False

Whether to use italic typeface.

leadingclass-attributeinstance-attribute​

leading: Number | None = None

The amount of additional space to place between lines when rendering text.

Defaults to using the font-specified leading value.

sizeclass-attributeinstance-attribute​

size: Number | None = None

The size of text (in logical pixels) to use when getting metrics from the font.

Defaults to 14.

weightclass-attributeinstance-attribute​

weight: FontWeight | None = None

The typeface thickness to use when calculating the strut.

Defaults to FontWeight.W_400.

Methods​

copy​

copy(
    size: Number | None = None,
    height: Number | None = None,
    weight: FontWeight | None = None,
    italic: bool | None = None,
    font_family: str | None = None,
    leading: Number | None = None,
    force_strut_height: bool | None = None,
) -> StrutStyle

Returns a copy of this object with the specified properties overridden.