CustomTextWidget class

A highly customizable text widget for Flutter that supports rich text, gradients, shadows, selectable text, and more.

Supports:

  • RichText with mentions (@user) and hashtags (#flutter)
  • Gradient text and animated gradients
  • Shadow and glow effects
  • Selectable text
  • Predefined style presets: title, subtitle, body, caption, buttonText
  • Pub.dev-ready text scaling with textScaler
Inheritance

Constructors

CustomTextWidget({Key? key, required String text, int maxLines = 1, TextAlign textAlign = TextAlign.start, Color? color, FontWeight fontWeight = FontWeight.w500, String fontFamily = 'regular', double fontSize = 16, double? minFontSize, double? maxFontSize, bool selectable = false, bool autoScale = false, TextOverflow overflow = TextOverflow.ellipsis, TextDecoration? decoration, List<Shadow>? shadows, Gradient? gradient, bool animatedGradient = false, bool richTextMode = false, void onTapWord(String word)?, TextPresets? preset})
Creates a CustomTextWidget.
const

Properties

animatedGradient bool
Enables animated gradient effect when set to true.
final
autoScale bool
Whether the text auto scales based on screen size.
final
color Color?
Color of the text.
final
decoration TextDecoration?
Text decoration (underline, line-through, etc.)
final
fontFamily String
Font family to use for the text.
final
fontSize double
Font size of the text.
final
fontWeight FontWeight
Font weight of the text.
final
gradient Gradient?
Optional gradient for the text.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
maxFontSize double?
Maximum font size when auto scaling is enabled.
final
maxLines int
Maximum number of lines for the text. Default is 1.
final
minFontSize double?
Minimum font size when auto scaling is enabled.
final
onTapWord → void Function(String word)?
Callback when a word (mention/hashtag) is tapped.
final
overflow TextOverflow
How visual overflow should be handled.
final
preset TextPresets?
Predefined text style presets.
final
richTextMode bool
Enable rich text parsing for mentions (@user), hashtags (#tag), emojis.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selectable bool
Whether the text can be selected by the user.
final
shadows List<Shadow>?
List of shadows applied to the text.
final
text String
The text to display.
final
textAlign TextAlign
How the text should be aligned horizontally.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<CustomTextWidget>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited