A paragraph of rich text.
The RichText widget displays text that uses multiple different styles. The text to display is described using a tree of TextSpan objects, each of which has an associated style that is used for that subtree. The text might break across multiple lines or might all be displayed on the same line depending on the layout constraints.
Text displayed in a RichText widget must be explicitly styled. When picking which style to use, consider using of the current BuildContext to provide defaults.
When all the text uses the same style, consider using the Text widget, which is less verbose and integrates with DefaultTextStyle for default styling.
Example:
new RichText(
text: new TextSpan(
text: 'Hello ',
style: DefaultTextStyle.of(context).style,
children: <TextSpan>[
new TextSpan(text: 'bold', style: new TextStyle(fontWeight: FontWeight.bold)),
new TextSpan(text: ' world!'),
],
),
),
See also:
- Inheritance
Constructors
Properties
- overflow → TextOverflow
-
How visual overflow should be handled.
read-only - softWrap → bool
-
Whether the text should break at soft line breaks.
read-only - text → TextSpan
-
The text to display in this widget.
read-only - textAlign → TextAlign
-
How the text should be aligned horizontally.
read-only - textScaleFactor → double
-
The number of font pixels for each logical pixel.
read-only - hashCode → int
-
Get a hash code for this object.
read-only, inherited - key → Key
-
Controls how one widget replaces another widget in the tree.
read-only, inherited - runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Operators
-
operator ==(
other) → bool -
The equality operator.
inherited
Methods
-
createRenderObject(
BuildContext context) → RenderParagraph -
Creates an instance of the
RenderObject
class that thisRenderObjectWidget
represents, using the configuration described by thisRenderObjectWidget
. -
updateRenderObject(
BuildContext context, RenderParagraph renderObject) → void -
Copies the configuration described by this
RenderObjectWidget
to the givenRenderObject
, which will be of the same type as returned by this object'screateRenderObject
. -
createElement(
) → LeafRenderObjectElement -
RenderObjectWidgets always inflate to a
RenderObjectElement
subclass.inherited -
debugFillDescription(
List<String> description) → void -
Add additional information to the given description for use by toString.
inherited -
didUnmountRenderObject(
RenderObject renderObject) → void -
A render object previously associated with this widget has been removed from the tree. The given RenderObject will be of the same type as returned by this object's createRenderObject.
inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed.
inherited -
toString(
) → String -
Returns a string representation of this object.
inherited -
toStringShort(
) → String -
A short, textual description of this widget.
inherited