Position
class
Hide inherited
class Position {
final int line;
final int character;
final int offset;
const Position(this.offset, this.line, this.character);
Position addChar(String c) {
assert(c.length == 1);
final isNewLine = c == '\n';
return new Position(
offset + 1,
line + (isNewLine ? 1 : 0),
isNewLine ? 1 : character + 1);
}
bool operator <(Position p) => offset < p.offset;
bool operator >(Position p) => offset > p.offset;
String toString() => '(line $line, char $character, offset $offset)';
}
Constructors
Code
const Position (int offset, int line, int character) #
Creates a new Object instance.
Object instances have no meaningful state, and are only useful
through their identity. An Object instance is equal to itself
only.
const Position(this.offset, this.line, this.character);
Properties
Code
final int character #
Operators
bool operator <(Position p) => offset < p.offset;
bool operator >(Position p) => offset > p.offset;
Methods
Position addChar(String c) {
assert(c.length == 1);
final isNewLine = c == '\n';
return new Position(
offset + 1,
line + (isNewLine ? 1 : 0),
isNewLine ? 1 : character + 1);
}
Code
String toString () #
Returns a string representation of this object.
String toString() => '(line $line, char $character, offset $offset)';