getParagraphStyle method Null safety
- {TextAlign? textAlign,
- TextDirection? textDirection,
- double textScaleFactor = 1.0,
- String? ellipsis,
- int? maxLines,
- TextHeightBehavior? textHeightBehavior,
- Locale? locale,
- String? fontFamily,
- double? fontSize,
- FontWeight? fontWeight,
- FontStyle? fontStyle,
- double? height,
- StrutStyle? strutStyle}
The style information for paragraphs, encoded for use by dart:ui
.
The textScaleFactor
argument must not be null. If omitted, it defaults
to 1.0. The other arguments may be null. The maxLines
argument, if
specified and non-null, must be greater than zero.
If the font size on this style isn't set, it will default to 14 logical pixels.
Implementation
ui.ParagraphStyle getParagraphStyle({
TextAlign? textAlign,
TextDirection? textDirection,
double textScaleFactor = 1.0,
String? ellipsis,
int? maxLines,
ui.TextHeightBehavior? textHeightBehavior,
Locale? locale,
String? fontFamily,
double? fontSize,
FontWeight? fontWeight,
FontStyle? fontStyle,
double? height,
StrutStyle? strutStyle,
}) {
assert(textScaleFactor != null);
assert(maxLines == null || maxLines > 0);
final ui.TextLeadingDistribution? leadingDistribution = this.leadingDistribution;
final ui.TextHeightBehavior? effectiveTextHeightBehavior = textHeightBehavior
?? (leadingDistribution == null ? null : ui.TextHeightBehavior(leadingDistribution: leadingDistribution));
return ui.ParagraphStyle(
textAlign: textAlign,
textDirection: textDirection,
// Here, we establish the contents of this TextStyle as the paragraph's default font
// unless an override is passed in.
fontWeight: fontWeight ?? this.fontWeight,
fontStyle: fontStyle ?? this.fontStyle,
fontFamily: fontFamily ?? this.fontFamily,
fontSize: (fontSize ?? this.fontSize ?? _kDefaultFontSize) * textScaleFactor,
height: height ?? this.height,
textHeightBehavior: effectiveTextHeightBehavior,
strutStyle: strutStyle == null ? null : ui.StrutStyle(
fontFamily: strutStyle.fontFamily,
fontFamilyFallback: strutStyle.fontFamilyFallback,
fontSize: strutStyle.fontSize == null ? null : strutStyle.fontSize! * textScaleFactor,
height: strutStyle.height,
leading: strutStyle.leading,
fontWeight: strutStyle.fontWeight,
fontStyle: strutStyle.fontStyle,
forceStrutHeight: strutStyle.forceStrutHeight,
),
maxLines: maxLines,
ellipsis: ellipsis,
locale: locale,
);
}