TextPosition class
A position in a string of text.
A TextPosition can be used to describe a caret position in between
characters. The offset points to the position between offset - 1
and
offset
characters of the string, and the affinity is used to describe
which character this position affiliates with.
One use case is when rendered text is forced to wrap. In this case, the offset where the wrap occurs could visually appear either at the end of the first line or the beginning of the second line. The second way is with bidirectional text. An offset at the interface between two different text directions could have one of two locations in the rendered text.
See the documentation for TextAffinity for more information on how TextAffinity disambiguates situations like these.
Constructors
- TextPosition({required int offset, TextAffinity affinity = TextAffinity.downstream})
-
Creates an object representing a particular position in a string.
const
Properties
- affinity → TextAffinity
-
Disambiguates cases where the position in the string given by offset
could represent two different visual positions in the rendered text. For
example, this can happen when text is forced to wrap, or when one string
of text is rendered with multiple text directions.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- offset → int
-
The index of the character that immediately follows the position in the
string representation of the text.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override