StrutStyle constructor

StrutStyle(
  1. {String? fontFamily,
  2. List<String>? fontFamilyFallback,
  3. double? fontSize,
  4. double? height,
  5. TextLeadingDistribution? leadingDistribution,
  6. double? leading,
  7. FontWeight? fontWeight,
  8. FontStyle? fontStyle,
  9. bool? forceStrutHeight}
)

Creates a new StrutStyle object.

  • fontFamily: The name of the font to use when painting the text (e.g., Roboto).

  • fontFamilyFallback: An ordered list of font family names that will be searched for when the font in fontFamily cannot be found.

  • fontSize: The size of glyphs (in logical pixels) to use when painting the text.

  • height: The minimum height of the line boxes, as a multiplier of the font size. The lines of the paragraph will be at least (height + leading) * fontSize tall when fontSize is not null. Omitting height will allow the minimum line height to take the height as defined by the font, which may not be exactly the height of the fontSize. When fontSize is null, there is no minimum line height. Tall glyphs due to baseline alignment or large TextStyle.fontSize may cause the actual line height after layout to be taller than specified here. The fontSize must be provided for this property to take effect.

  • leading: The minimum amount of leading between lines as a multiple of the font size. fontSize must be provided for this property to take effect. The leading added by this property is distributed evenly over and under the text, regardless of leadingDistribution.

  • leadingDistribution: how the extra vertical space added by the height multiplier should be distributed over and under the text, independent of leading (which is always distributed evenly over and under text). Defaults to the paragraph's TextHeightBehavior's leading distribution.

  • fontWeight: The typeface thickness to use when painting the text (e.g., bold).

  • fontStyle: The typeface variant to use when drawing the letters (e.g., italics).

  • forceStrutHeight: When true, the paragraph will force all lines to be exactly (height + leading) * fontSize tall from baseline to baseline. TextStyle is no longer able to influence the line height, and any tall glyphs may overlap with lines above. If a fontFamily is specified, the total ascent of the first line will be the min of the Ascent + half-leading of the fontFamily and (height + leading) * fontSize. Otherwise, it will be determined by the Ascent + half-leading of the first text.

Implementation

StrutStyle({
  String? fontFamily,
  List<String>? fontFamilyFallback,
  double? fontSize,
  double? height,
  TextLeadingDistribution? leadingDistribution,
  double? leading,
  FontWeight? fontWeight,
  FontStyle? fontStyle,
  bool? forceStrutHeight,
}) : _encoded = _encodeStrut(
       fontFamily,
       fontFamilyFallback,
       fontSize,
       height,
       leadingDistribution,
       leading,
       fontWeight,
       fontStyle,
       forceStrutHeight,
     ),
     _leadingDistribution = leadingDistribution,
     _fontFamily = fontFamily,
     _fontFamilyFallback = fontFamilyFallback;