TextSelection class

A range of text that represents a selection.

Inheritance
Annotations

Constructors

TextSelection({required int baseOffset, required int extentOffset, TextAffinity affinity = TextAffinity.downstream, bool isDirectional = false})
Creates a text selection.
const
TextSelection.collapsed({required int offset, TextAffinity affinity = TextAffinity.downstream})
Creates a collapsed selection at the given offset.
const
TextSelection.fromPosition(TextPosition position)
Creates a collapsed selection at the given text position.

Properties

affinity TextAffinity
If the text range is collapsed and has more than one visual location (e.g., occurs at a line break), which of the two locations to use when painting the caret.
final
base TextPosition
The position at which the selection originates.
no setter
baseOffset int
The offset at which the selection originates.
final
end int
The next index after the characters in this range.
finalinherited
extent TextPosition
The position at which the selection terminates.
no setter
extentOffset int
The offset at which the selection terminates.
final
hashCode int
The hash code for this object.
no setteroverride
isCollapsed bool
Whether this range is empty (but still potentially placed inside the text).
no setterinherited
isDirectional bool
Whether this selection has disambiguated its base and extent.
final
isNormalized bool
Whether the start of this range precedes the end.
no setterinherited
isValid bool
Whether this range represents a valid position in the text.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
start int
The index of the first character in the range.
finalinherited

Methods

copyWith({int? baseOffset, int? extentOffset, TextAffinity? affinity, bool? isDirectional}) TextSelection
Creates a new TextSelection based on the current selection, with the provided parameters overridden.
expandTo(TextPosition position, [bool extentAtIndex = false]) TextSelection
Returns the smallest TextSelection that this could expand to in order to include the given TextPosition.
extendTo(TextPosition position) TextSelection
Keeping the selection's TextSelection.baseOffset fixed, pivot the TextSelection.extentOffset to the given TextPosition.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
textAfter(String text) String
The text after this range.
inherited
textBefore(String text) String
The text before this range.
inherited
textInside(String text) String
The text inside this range.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override