StringView class Null safety

A wrapper class for Strings which adds a cursor tracking an offset in the string.

A StringView allows a String to be consumed from start to end, as well as providing operations that are especially useful for argument parsing.


StringView(String buffer, {bool isRestBlock = false})
Create a new StringView wrapping buffer.


buffer String
The string wrapped by this StringView.
current String
The character at the current cursor position.
end int
The largest possible index for the cursor.
eof bool
Whether the entire buffer has been consumed.
hashCode int
The hash code for this object.
history List<int>
A record of all the previous indices the cursor was at preceding an operation.
read / write
index int
The current index of the cursor in buffer.
read / write
isRestBlock bool
Whether remaining should be considered to be one "block" of text, which getQuotedWord will return all of.
read / write
isWhitespace bool
Whether the current character is whitespace.
remaining String
The part of buffer that has yet to be consumed, spanning from index to the end of buffer.
runtimeType Type
A representation of the runtime type of the object.


copy() StringView
Create a copy of this StringView, with an identical buffer and index.
escape(int start, int end) String
Escape and return a portion of buffer.
getQuotedWord() String
Consume and return the next word or quoted portion in buffer.
getWord() String
Consume and return the next word in buffer, disregarding quotes.
isEscaped(int index) bool
Return whether the character at index is escaped.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
skipString(String s) bool
Skip over s and return true if s matches the text after the cursor, and return false otherwise.
skipWhitespace() → void
Skip to the next non-whitespace character in buffer.
toString() String
A string representation of this object.
undo() → void
Revert the previous operation if there is one.


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