RichText constructor

RichText(
  1. {Key? key,
  2. required InlineSpan text,
  3. TextAlign textAlign = TextAlign.start,
  4. TextDirection? textDirection,
  5. bool softWrap = true,
  6. TextOverflow overflow = TextOverflow.clip,
  7. @Deprecated('Use textScaler instead. ' 'Use of textScaleFactor was deprecated in preparation for the upcoming nonlinear text scaling support. ' 'This feature was deprecated after v3.12.0-2.0.pre.') double textScaleFactor = 1.0,
  8. TextScaler textScaler = TextScaler.noScaling,
  9. int? maxLines,
  10. Locale? locale,
  11. StrutStyle? strutStyle,
  12. TextWidthBasis textWidthBasis = TextWidthBasis.parent,
  13. TextHeightBehavior? textHeightBehavior,
  14. SelectionRegistrar? selectionRegistrar,
  15. Color? selectionColor}
)

Creates a paragraph of rich text.

The maxLines property may be null (and indeed defaults to null), but if it is not null, it must be greater than zero.

The textDirection, if null, defaults to the ambient Directionality, which in that case must not be null.

Implementation

RichText({
  super.key,
  required this.text,
  this.textAlign = TextAlign.start,
  this.textDirection,
  this.softWrap = true,
  this.overflow = TextOverflow.clip,
  @Deprecated(
    'Use textScaler instead. '
    'Use of textScaleFactor was deprecated in preparation for the upcoming nonlinear text scaling support. '
    'This feature was deprecated after v3.12.0-2.0.pre.',
  )
  double textScaleFactor = 1.0,
  TextScaler textScaler = TextScaler.noScaling,
  this.maxLines,
  this.locale,
  this.strutStyle,
  this.textWidthBasis = TextWidthBasis.parent,
  this.textHeightBehavior,
  this.selectionRegistrar,
  this.selectionColor,
}) : assert(maxLines == null || maxLines > 0),
     assert(selectionRegistrar == null || selectionColor != null),
     assert(textScaleFactor == 1.0 || identical(textScaler, TextScaler.noScaling), 'Use textScaler instead.'),
     textScaler = _effectiveTextScalerFrom(textScaler, textScaleFactor),
     super(children: WidgetSpan.extractFromInlineSpan(text, _effectiveTextScalerFrom(textScaler, textScaleFactor)));