RichText class

A widget that displays formatted text using a tree of TextSpan configurations.

Supports text wrapping, horizontal alignment (left, center, right), and maximum line boundaries.

Example

RichText(
  textAlign: TextAlign.center,
  text: TextSpan(
    text: 'Hello ',
    children: [
      TextSpan(
        text: 'World',
        style: Style(modifiers: Modifier.bold),
      ),
    ],
  ),
)
Inheritance

Constructors

RichText({required TextSpan text, bool wrap = true, TextAlign textAlign = TextAlign.left, int? maxLines})
Creates a RichText rendering widget configuring layout behavior around a root text span.
const

Properties

hashCode → int
The hash code for this object.
no setterinherited
key → Key?
The optional key for this widget.
finalinherited
maxLines → int?
The maximum number of lines allowed to render; clips any overflow.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
text → TextSpan
The root text span tree representing the structured formatted content.
final
textAlign → TextAlign
The horizontal alignment of the text lines.
final
wrap → bool
Whether the text should automatically wrap to fit the layout width.
final

Methods

createElement() → Element
Creates an Element to manage this widget's location in the tree.
override
getIntrinsicHeight(int width) → int
Computes the intrinsic height of this widget under the given width constraint.
inherited
getIntrinsicWidth(int height) → int
Computes the intrinsic width of this widget under the given height constraint.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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