Text method
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,
- TextLeadingDistribution? leadingDistribution,
- Locale? locale,
- Paint? foreground,
- Paint? background,
- List<
Shadow> ? shadows, - List<
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,
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;
}