ParagraphStyle constructor
- TextAlign? textAlign,
- TextDirection? textDirection,
- int? maxLines,
- String? fontFamily,
- double? fontSize,
- double? height,
- TextHeightBehavior? textHeightBehavior,
- FontWeight? fontWeight,
- FontStyle? fontStyle,
- StrutStyle? strutStyle,
- String? ellipsis,
- Locale? locale,
Creates a new ParagraphStyle object.
-
textAlign
: The alignment of the text within the lines of the paragraph. If the last line is ellipsized (seeellipsis
below), the alignment is applied to that line after it has been truncated but before the ellipsis has been added. See: https://github.com/flutter/flutter/issues/9819 -
textDirection
: The directionality of the text, left-to-right (e.g. Norwegian) or right-to-left (e.g. Hebrew). This controls the overall directionality of the paragraph, as well as the meaning of TextAlign.start and TextAlign.end in thetextAlign
field. -
maxLines
: The maximum number of lines painted. Lines beyond this number are silently dropped. For example, ifmaxLines
is 1, then only one line is rendered. IfmaxLines
is null, butellipsis
is not null, then lines after the first one that overflows the width constraints are dropped. The width constraints are those set in the ParagraphConstraints object passed to the Paragraph.layout method. -
fontFamily
: The name of the font family to apply when painting the text, in the absence of atextStyle
being attached to the span. -
fontSize
: The fallback size of glyphs (in logical pixels) to use when painting the text. This is used when there is no TextStyle. -
height
: The fallback height of the spans as a multiplier of the font size. The fallback height is used when no height is provided throughTextStyle.height
. Omittingheight
here (or setting it to kTextHeightNone) and in TextStyle will allow the line height to take the height as defined by the font, which may not be exactly the height of thefontSize
. -
textHeightBehavior
: Specifies how theheight
multiplier is applied to ascent of the first line and the descent of the last line. -
leadingDistribution
: Specifies how the extra vertical space added by theheight
multiplier should be distributed over and under the text. Defaults to TextLeadingDistribution.proportional. -
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). -
strutStyle
: The properties of the strut. Strut defines a set of minimum vertical line height related metrics and can be used to obtain more advanced line spacing behavior. -
ellipsis
: String used to ellipsize overflowing text. IfmaxLines
is not null, then theellipsis
, if any, is applied to the last rendered line, if that line overflows the width constraints. IfmaxLines
is null, then theellipsis
is applied to the first line that overflows the width constraints, and subsequent lines are dropped. The width constraints are those set in the ParagraphConstraints object passed to the Paragraph.layout method. The empty string and the null value are considered equivalent and turn off this behavior. -
locale
: The locale used to select region-specific glyphs.
Implementation
ParagraphStyle({
TextAlign? textAlign,
TextDirection? textDirection,
int? maxLines,
String? fontFamily,
double? fontSize,
double? height,
TextHeightBehavior? textHeightBehavior,
FontWeight? fontWeight,
FontStyle? fontStyle,
StrutStyle? strutStyle,
String? ellipsis,
Locale? locale,
}) : _encoded = _encodeParagraphStyle(
textAlign,
textDirection,
maxLines,
fontFamily,
fontSize,
height,
textHeightBehavior,
fontWeight,
fontStyle,
strutStyle,
ellipsis,
locale,
),
_fontFamily = fontFamily,
_fontSize = fontSize,
_height = height,
_strutStyle = strutStyle,
_ellipsis = ellipsis,
_locale = locale,
_leadingDistribution = textHeightBehavior?.leadingDistribution ?? TextLeadingDistribution.proportional;