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.
inherited
getIntrinsicHeight(int width) int
Computes the intrinsic height of this widget under the given width constraint.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
render(Buffer buffer, Rect area) → void
Renders the widget onto the provided buffer within the specified area.
override
toString() String
A string representation of this object.
inherited

Operators

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