An object that paints a TextSpan tree into a Canvas.
To use a TextPainter, follow these steps:
-
Create a TextSpan tree and pass it to the TextPainter constructor.
-
Call layout to prepare the paragraph.
-
Call paint as often as desired to paint the paragraph.
If the width of the area into which the text is being painted changes, return to step 2. If the text to be painted changes, return to step 1.
Constructors
- TextPainter({TextSpan text, TextAlign textAlign, double textScaleFactor: 1.0, String ellipsis })
-
Creates a text painter that paints the given text.
Properties
- ellipsis → String
-
The string used to ellipsize overflowing text. Setting this to a nonempty string will cause this string to be substituted for the remaining text if the text can not fit within the specificed maximum width.
read / write - height → double
-
The vertical space required to paint this text.
read-only - maxIntrinsicWidth → double
-
The width at which increasing the width of the text no longer decreases the height.
read-only - minIntrinsicWidth → double
-
The width at which decreasing the width of the text would prevent it from painting itself completely within its bounds.
read-only - size → Size
-
The amount of space required to paint this text.
read-only - text → TextSpan
-
The (potentially styled) text to paint.
read / write - textAlign → TextAlign
-
How the text should be aligned horizontally.
read / write - textScaleFactor → double
-
The number of font pixels for each logical pixel.
read / write - width → double
-
The horizontal space required to paint this text.
read-only - hashCode → int
-
Get a hash code for this object.
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
-
computeDistanceToActualBaseline(
TextBaseline baseline) → double -
Returns the distance from the top of the text to the first baseline of the given type.
-
getBoxesForSelection(
TextSelection selection) → List<TextBox> -
Returns a list of rects that bound the given selection.
-
getOffsetForCaret(
TextPosition position, Rect caretPrototype) → Offset -
Returns the offset at which to paint the caret.
-
getPositionForOffset(
Offset offset) → TextPosition -
Returns the position within the text for the given pixel offset.
-
getWordBoundary(
TextPosition position) → TextRange -
Returns the text range of the word at the given offset. Characters not part of a word, such as spaces, symbols, and punctuation, have word breaks on both sides. In such cases, this method will return a text range that contains the given text position.
-
layout(
{double minWidth: 0.0, double maxWidth: double.INFINITY }) → void -
Computes the visual position of the glyphs for painting the text.
-
paint(
Canvas canvas, Offset offset) → void -
Paints the text onto the given canvas at the given offset.
-
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