Text method

RichTextBuilder Text({
  1. String? text,
  2. TextStyle? baseStyle,
  3. bool? inherit,
  4. TextAlign? align,
  5. bool? centerAlign,
  6. bool? leftAlign,
  7. bool? rightAlign,
  8. bool? softWrap,
  9. bool? nowrap,
  10. Color? color,
  11. Color? backgroundColor,
  12. double? fontSize,
  13. FontWeight? fontWeight,
  14. int? fontWeightInt,
  15. bool? weightBlack,
  16. bool? weightBold,
  17. bool? weightLight,
  18. FontStyle? fontStyle,
  19. double? letterSpacing,
  20. double? wordSpacing,
  21. TextBaseline? textBaseline,
  22. double? height,
  23. TextLeadingDistribution? leadingDistribution,
  24. Locale? locale,
  25. Paint? foreground,
  26. Paint? background,
  27. List<Shadow>? shadows,
  28. List<FontFeature>? fontFeatures,
  29. TextDecoration? decoration,
  30. Color? decorationColor,
  31. TextDecorationStyle? decorationStyle,
  32. double? decorationThickness,
  33. String? debugLabel,
  34. String? fontFamily,
  35. List<String>? fontFamilyFallback,
  36. String? package,
  37. TextOverflow? overflow,
  38. bool? clip,
  39. bool? fade,
  40. bool? ellipses,
  41. FutureBuildCallback? gesture,
  42. int? maxLines,
  43. double? widgetHeight,
})

Implementation

RichTextBuilder Text({
  String? text,
  TextStyle? baseStyle,
  bool? inherit,
  TextAlign? align,
  bool? centerAlign,
  bool? leftAlign,
  bool? rightAlign,
  bool? softWrap,
  bool? nowrap,
  Color? color,
  Color? backgroundColor,
  double? fontSize,
  FontWeight? fontWeight,
  int? fontWeightInt,
  bool? weightBlack,
  bool? weightBold,
  bool? weightLight,
  FontStyle? fontStyle,
  double? letterSpacing,
  double? wordSpacing,
  TextBaseline? textBaseline,
  double? height,
  ui.TextLeadingDistribution? leadingDistribution,
  Locale? locale,
  Paint? foreground,
  Paint? background,
  List<ui.Shadow>? shadows,
  List<ui.FontFeature>? fontFeatures,
  TextDecoration? decoration,
  Color? decorationColor,
  TextDecorationStyle? decorationStyle,
  double? decorationThickness,
  String? debugLabel,
  String? fontFamily,
  List<String>? fontFamilyFallback,
  String? package,
  TextOverflow? overflow,
  bool? clip,
  bool? fade,
  bool? ellipses,
  FutureBuildCallback? gesture,
  int? maxLines,
  double? widgetHeight,
}) {
  switch (fontWeightInt) {
    case null:
      break;
    case 1:
    case 100:
      fontWeight = FontWeight.w100;
      break;
    case 2:
    case 200:
      fontWeight = FontWeight.w200;
      break;
    case 3:
    case 300:
      fontWeight = FontWeight.w300;
      break;
    case 4:
    case 400:
      fontWeight = FontWeight.w400;
      break;
    case 5:
    case 500:
      fontWeight = FontWeight.w500;
      break;
    case 6:
    case 600:
      fontWeight = FontWeight.w600;
      break;
    case 7:
    case 700:
      fontWeight = FontWeight.w700;
      break;
    case 8:
    case 800:
      fontWeight = FontWeight.w800;
      break;
    case 9:
    case 900:
      fontWeight = FontWeight.w900;
      break;
    default:
      throw ArgumentError("Invalid argument for fontWeightInt.  Must be 1-9, 100-900, or null.  Was ${fontWeightInt}");
  }
  fontWeight ??= weightBlack == true
      ? FontWeight.w900
      : weightBold == true
          ? FontWeight.bold
          : weightLight == true
              ? FontWeight.w100
              : null;
  final _base = (baseStyle ?? Theme.of(this).textTheme.bodyText1 ?? const TextStyle()).copyWith(
    inherit: inherit ?? false,
    color: color,
    backgroundColor: backgroundColor,
    fontSize: fontSize,
    fontWeight: fontWeight,
    fontStyle: fontStyle,
    letterSpacing: letterSpacing,
    wordSpacing: wordSpacing,
    textBaseline: textBaseline,
    height: height,
    leadingDistribution: leadingDistribution,
    locale: locale,
    foreground: foreground,
    background: background,
    shadows: shadows,
    fontFeatures: fontFeatures,
    decoration: decoration,
    decorationColor: decorationColor,
    decorationStyle: decorationStyle,
    decorationThickness: decorationThickness,
    debugLabel: debugLabel,
    fontFamily: fontFamily,
    fontFamilyFallback: fontFamilyFallback,
    package: package,
    overflow: overflow,
  );
  var builder = RichTextBuilder(this, start: _base);
  align = align ??
      (centerAlign == true
          ? TextAlign.center
          : leftAlign == true
              ? TextAlign.left
              : rightAlign == true
                  ? TextAlign.right
                  : null);
  if (align != null) {
    builder._textAlign = align;
  }
  if (softWrap != null) {
    builder._softWrap = softWrap;
  }
  if (nowrap != null) {
    builder._softWrap = !nowrap;
  }
  if (overflow != null) builder._overflow = overflow;
  builder._gesture = gesture;
  builder._maxLines = maxLines;
  builder._height = widgetHeight;
  overflow ??= clip == true
      ? TextOverflow.clip
      : ellipses == true
          ? TextOverflow.ellipsis
          : fade == true
              ? TextOverflow.fade
              : null;

  if (overflow != null) builder._overflow = overflow;
  if (text != null) builder.text(text, style: baseStyle);
  return builder;
}