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.
Constructors
- StringView(String buffer, {bool isRestBlock = false})
- Create a new StringView wrapping buffer.
Properties
- buffer → String
-
The string wrapped by this StringView.
final
- current → String
-
The character at the current cursor position.
read-only
- end → int
-
The largest possible index for the cursor.
read-only
- eof → bool
-
Whether the entire buffer has been consumed.
read-only
- hashCode → int
-
The hash code for this object.
read-onlyinherited
-
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.
read-only
- remaining → String
-
The part of buffer that has yet to be consumed, spanning from index to the end of
buffer.
read-only
- runtimeType → Type
-
A representation of the runtime type of the object.
read-onlyinherited
Methods
-
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.
inherited
-
skipString(
String s) → bool -
Skip over
s
and returntrue
ifs
matches the text after the cursor, and returnfalse
otherwise. -
skipWhitespace(
) → void - Skip to the next non-whitespace character in buffer.
-
toString(
) → String -
A string representation of this object.
override
-
undo(
) → void - Revert the previous operation if there is one.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited