asText method

Text asText({
  1. TextStyle? style,
  2. StrutStyle? strutStyle,
  3. TextAlign? textAlign,
  4. TextDirection? textDirection,
  5. Locale? locale,
  6. bool? softWrap,
  7. TextOverflow? overflow,
  8. TextScaler? textScaler,
  9. int? maxLines,
  10. String? semanticsLabel,
  11. TextWidthBasis? textWidthBasis,
  12. String defaultText = "",
  13. bool validate = true,
})

Converts the object to a Text widget with the specified properties.

If the object is null, it returns defaultText in a Text widget. If the object is already a Text widget, it returns the object itself. If validate is true and the object is not valid (see isValid()), it returns defaultText in a Text widget. Otherwise, it converts the object to a Text widget with the default text.

The style, strutStyle, textAlign, textDirection, locale, softWrap, overflow, textScaler, maxLines, semanticsLabel, and textWidthBasis parameters are used to customize the appearance and behavior of the Text widget.

Returns a Text widget with the specified properties.

Implementation

Text asText({
  TextStyle? style,
  StrutStyle? strutStyle,
  TextAlign? textAlign,
  TextDirection? textDirection,
  Locale? locale,
  bool? softWrap,
  TextOverflow? overflow,
  TextScaler? textScaler,
  int? maxLines,
  String? semanticsLabel,
  TextWidthBasis? textWidthBasis,
  String defaultText = "",
  bool validate = true,
}) =>
    asNullableText(
      style: style,
      strutStyle: strutStyle,
      textAlign: textAlign,
      textDirection: textDirection,
      locale: locale,
      softWrap: softWrap,
      overflow: overflow,
      textScaler: textScaler,
      maxLines: maxLines,
      semanticsLabel: semanticsLabel,
      textWidthBasis: textWidthBasis,
      validate: validate,
    )!;