CodeLinePosition class

A position in a string of code.

A CodeLinePosition can be used to describe a caret position in between characters. The index points to the line index and 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.

Inheritance

Constructors

CodeLinePosition({required int index, required int offset, TextAffinity affinity = TextAffinity.downstream})
Creates an object representing a particular position in a code.
const
CodeLinePosition.from({required int index, required TextPosition position})
Creates the CodeLinePosition with the line index and text position.

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.
finalinherited
hashCode int
The hash code for this object.
no setteroverride
index int
Line index in the codes.
final
offset int
The index of the character that immediately follows the position in the string representation of the text.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
textPosition TextPosition
Get the text position withou line index.
no setter

Methods

copyWith({int? index, int? offset, TextAffinity? affinity}) CodeLinePosition
isAfter(CodeLinePosition position) bool
Whether the current code position is after the given position.
isBefore(CodeLinePosition position) bool
Whether the current code position is before the given position.
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