Dart DocumentationparsersPosition

Position class

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;
}

Constructors

const Position(int offset, int line, int character) #

const Position(this.offset, this.line, this.character);

Properties

final int character #

final int character;

final int line #

final int line;

final int offset #

final int offset;

Operators

bool operator <(Position p) #

bool operator <(Position p) => offset < p.offset;

bool operator >(Position p) #

bool operator >(Position p) => offset > p.offset;

Methods

Position addChar(String c) #

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);
}