TextExtensions extension
Extension methods for Text widgets that provide convenient text modification functionality.
This extension adds methods to easily modify existing Text widgets by creating new instances with updated properties. All methods return new Text widgets without modifying the original widget, following Flutter's immutable widget pattern.
The extension provides both granular control (individual property setters) and comprehensive styling (styled method) for text appearance and behavior modification.
Text Properties Supported:
- Layout: textAlign, textDirection, maxLines, overflow, softWrap
- Styling: fontSize, fontWeight, fontStyle, color, decoration
- Advanced: strutStyle, textScaler, semanticsLabel, heightBehavior
- Typography: letterSpacing, wordSpacing, height, fontFamily
Example usage:
Text('Hello World')
.fontSize(18)
.bold()
.textAlign(TextAlign.center)
.maxLines(2);
- on
Methods
-
background(
Paint paint) → Text -
Available on Text, provided by the TextExtensions extension
Sets the background paint for the text. -
bold(
) → Text -
Available on Text, provided by the TextExtensions extension
Makes the text bold. -
boldItalic(
) → Text -
Available on Text, provided by the TextExtensions extension
Makes the text bold and italic. -
boldStrikethrough(
) → Text -
Available on Text, provided by the TextExtensions extension
Makes the text bold with strikethrough. -
boldUnderline(
) → Text -
Available on Text, provided by the TextExtensions extension
Makes the text bold and underlined. -
debugLabel(
String label) → Text -
Available on Text, provided by the TextExtensions extension
Sets the debug label for the text style. -
decoration(
TextDecoration decoration) → Text -
Available on Text, provided by the TextExtensions extension
Sets the text decoration for the text. -
decorationColor(
Color color) → Text -
Available on Text, provided by the TextExtensions extension
Sets the decoration color for the text. -
decorationStyle(
TextDecorationStyle style) → Text -
Available on Text, provided by the TextExtensions extension
Sets the decoration style for the text. -
decorationThickness(
double thickness) → Text -
Available on Text, provided by the TextExtensions extension
Sets the decoration thickness for the text. -
fontFamily(
String family) → Text -
Available on Text, provided by the TextExtensions extension
Sets the font family for the text. -
fontFamilyFallback(
List< String> fallback) → Text -
Available on Text, provided by the TextExtensions extension
Sets the fallback font families for the text. -
fontFeatures(
List< FontFeature> features) → Text -
Available on Text, provided by the TextExtensions extension
Sets the font features for the text. -
fontSize(
double size) → Text -
Available on Text, provided by the TextExtensions extension
Sets the font size for the text. -
fontStyle(
FontStyle style) → Text -
Available on Text, provided by the TextExtensions extension
Sets the font style for the text. -
fontVariations(
List< FontVariation> variations) → Text -
Available on Text, provided by the TextExtensions extension
Sets the font variations for the text. -
fontWeight(
FontWeight weight) → Text -
Available on Text, provided by the TextExtensions extension
Sets the font weight for the text. -
foreground(
Paint paint) → Text -
Available on Text, provided by the TextExtensions extension
Sets the foreground paint for the text. -
height(
double height) → Text -
Available on Text, provided by the TextExtensions extension
Sets the line height multiplier for the text. -
italic(
) → Text -
Available on Text, provided by the TextExtensions extension
Makes the text italic. -
leadingDistribution(
TextLeadingDistribution distribution) → Text -
Available on Text, provided by the TextExtensions extension
Sets the leading distribution for the text. -
letterSpacing(
double spacing) → Text -
Available on Text, provided by the TextExtensions extension
Sets the letter spacing for the text. -
shadows(
List< Shadow> shadows) → Text -
Available on Text, provided by the TextExtensions extension
Sets the shadows for the text. -
strikethrough(
) → Text -
Available on Text, provided by the TextExtensions extension
Adds strikethrough decoration to the text. -
styled(
{Color? color, Color? backgroundColor, double? fontSize, FontWeight? fontWeight, FontStyle? fontStyle, double? letterSpacing, double? wordSpacing, TextBaseline? textBaseline, double? height, TextLeadingDistribution? leadingDistribution, Locale? locale, Paint? foreground, Paint? background, List< Shadow> ? shadows, List<FontFeature> ? fontFeatures, List<FontVariation> ? fontVariations, TextDecoration? decoration, Color? decorationColor, TextDecorationStyle? decorationStyle, double? decorationThickness, String? debugLabel, String? fontFamily, List<String> ? fontFamilyFallback, String? package, TextOverflow? overflow, bool? inherit}) → Text -
Available on Text, provided by the TextExtensions extension
Applies comprehensive styling to the text widget. -
underline(
) → Text -
Available on Text, provided by the TextExtensions extension
Adds underline decoration to the text. -
withHeightBehavior(
TextHeightBehavior behavior) → Text -
Available on Text, provided by the TextExtensions extension
Sets the text height behavior for line height calculation. -
withLocale(
Locale locale) → Text -
Available on Text, provided by the TextExtensions extension
Sets the locale for the text widget. -
withMaxLines(
int maxLines) → Text -
Available on Text, provided by the TextExtensions extension
Sets the maximum number of lines for the text. -
withOverflow(
TextOverflow overflow) → Text -
Available on Text, provided by the TextExtensions extension
Sets how text overflow should be handled. -
withSelectionColor(
Color color) → Text -
Available on Text, provided by the TextExtensions extension
Sets the selection color for selectable text. -
withSemanticsLabel(
String semanticsLabel) → Text -
Available on Text, provided by the TextExtensions extension
Sets the semantic label for accessibility. -
withSoftWrap(
bool softWrap) → Text -
Available on Text, provided by the TextExtensions extension
Sets whether the text should wrap at soft line breaks. -
withStrutStyle(
StrutStyle style) → Text -
Available on Text, provided by the TextExtensions extension
Sets the strut style for the text. -
withTextAlign(
TextAlign align) → Text -
Available on Text, provided by the TextExtensions extension
Sets the text alignment for the text widget. -
withTextDirection(
TextDirection direction) → Text -
Available on Text, provided by the TextExtensions extension
Sets the text direction for the text widget. -
withTextScaler(
TextScaler scaler) → Text -
Available on Text, provided by the TextExtensions extension
Sets the text scaler for the text. -
withWidthBasis(
TextWidthBasis basis) → Text -
Available on Text, provided by the TextExtensions extension
Sets the text width basis for measuring text width. -
wordSpacing(
double spacing) → Text -
Available on Text, provided by the TextExtensions extension
Sets the word spacing for the text.