extent property
The position at which the selection terminates.
When the user uses the arrow keys to adjust the selection, this is the value that changes. Similarly, if the current theme paints a caret on one side of the selection, this is the location at which to paint the caret.
The TextAffinity of the resulting TextPosition is based on the relative logical position in the text to the other selection endpoint:
- if baseOffset < extentOffset, base will have TextAffinity.downstream and extent will have TextAffinity.upstream.
- if baseOffset > extentOffset, base will have TextAffinity.upstream and extent will have TextAffinity.downstream.
- if baseOffset == extentOffset, base and extent will both have the collapsed selection's affinity.
Might be larger than, smaller than, or equal to base.
Implementation
TextPosition get extent {
final TextAffinity affinity;
if (!isValid || baseOffset == extentOffset) {
affinity = this.affinity;
} else if (baseOffset < extentOffset) {
affinity = TextAffinity.upstream;
} else {
affinity = TextAffinity.downstream;
}
return TextPosition(offset: extentOffset, affinity: affinity);
}