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.
- 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.
- hashCode → int
The hash code for this object.
- offset → int
The index of the character that immediately follows the position in the
string representation of the text.
- runtimeType → Type
A representation of the runtime type of the object.