CharacterRange class Null safety

A range of characters of a Characters.

A range of consecutive characters in source, corresponding to a start and end position in the source sequence. The range may even be empty, but that will still correspond to a position where both start and end happen to be the same position.

The source sequence can be separated into the preceeding characters, those before the range, the range itself, and the following characters, those after the range.

Some operations inspect or act on the characters of the current range, and other operations modify the range by moving the start and/or end position.

In general, an operation with a name starting with move will move both start and end positions, selecting an entirely new range which does not overlap the current range. Operations starting with collapse reduces the current range to a sub-range of itself. Operations starting with expand increase the current range by moving/ the end postion to a later position or the start position to an earlier position, and operations starting with drop reduce the current range by moving the start to a later position or the end to an earlier position, therebyt dropping characters from one or both ends from the current range.

The character range implements Iterator The moveNext operation, when called with no argument, iterates the next single characters of the source sequence.

Implemented types

Constructors

CharacterRange(String string)
Creates a new character iterator iterating the character of string.
factory
CharacterRange.at(String string, int startIndex, [int? endIndex])
Creates a new character iterator on string.
factory

Properties

charactersAfter Characters
The characters after the current range.
read-only
charactersBefore Characters
The characters before the current range.
read-only
current String
The current element.
read-onlyinherited
currentCharacters Characters
The characters of this range.
read-only
hashCode int
The hash code for this object.
read-onlyinherited
isEmpty bool
Whether the current range is empty.
read-only
isNotEmpty bool
Whether the current range is not empty.
read-only
runes Runes
The code points of the current character range.
read-only
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited
source Characters
The character sequence that this range is a sub-sequence of.
read-only
stringAfter String
The string of the characters after the current range.
read-only
stringAfterLength int
The length, in code units, of stringAfter.
read-only
stringBefore String
The string of the characters before the current range.
read-only
stringBeforeLength int
The length, in code units, of stringBefore.
read-only
utf16CodeUnits Iterable<int>
The code units of the current character range.
read-only

Methods

collapseToEnd() → void
Collapses the range to its end.
collapseToFirst(Characters target) bool
Collapses to the first occurrence of target in the current range.
collapseToLast(Characters target) bool
Collapses to the last occurrence of target in the current range.
collapseToStart() → void
Collapses the range to its start.
copy() CharacterRange
Creates a copy of this CharacterRange.
dropBackTo(Characters target) bool
Drops the last occurrence of target in the range.
dropBackUntil(Characters target) bool
Drops characters from the end of the range until after the last occurrence of target.
dropBackWhile(bool test(String)) → void
Drops characters from the end of the range while they satisfy test.
dropFirst([int count = 1]) bool
Drop the first count characters from the range.
dropLast([int count = 1]) bool
Drop the last count characters from the range.
dropTo(Characters target) bool
Drops the first occurrence of target in the range.
dropUntil(Characters target) bool
Drops characters from the start of the range until before the first occurrence of target.
dropWhile(bool test(String)) → void
Drops characters from the start of the range while they satisfy test.
endsWith(Characters characters) bool
Whether the current range ends with characters.
expandAll() → void
Expands the range to the end of source.
expandBack([int count = 1]) bool
Expands the current range with the preceding count characters.
expandBackAll() → void
Expands the range back to the start of source.
expandBackTo(Characters target) bool
Expands the range to include the previous occurence of target.
expandBackUntil(Characters target) bool
Expands the range to include characters back until the previous target.
expandBackWhile(bool test(String)) → void
Expands the range with the preceding characters satisffying test.
expandNext([int count = 1]) bool
Expands the current range with the next count characters.
expandTo(Characters target) bool
Expands the range to include the next occurence of target.
expandUntil(Characters target) bool
Expands the range to include characters until the next target.
expandWhile(bool test(String)) → void
Expands the range with the following characters satisfying test.
isFollowedBy(Characters characters) bool
Whether the current range is followed by characters.
isPrecededBy(Characters characters) bool
Whether the current range is preceded by characters.
moveBack([int count = 1]) bool
Moves the range to be the last count characters before the current range.
moveBackAll() → void
Moves the range to be everything before the current range.
moveBackTo(Characters target) bool
Moves the range to the last occurrence of target before the current range.
moveBackUntil(Characters target) bool
Moves to the range after the previous occurence of target.
moveNext([int count = 1]) bool
Moves the range to be the next count characters after the current range.
override
moveNextAll() → void
Moves the range to be everything after the current range.
moveTo(Characters target) bool
Moves the range to the next occurrence of target after the current range.
moveUntil(Characters target) bool
Moves to the range until the next occurrence of target.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
replaceAll(Characters pattern, Characters replacement) CharacterRange?
Replaces pattern in the current range with replacement.
replaceFirst(Characters pattern, Characters replacement) CharacterRange?
Replaces the first occurrence of pattern with replacement.
replaceRange(Characters replacement) CharacterRange
Replaces the current range with replacement and returns the result.
split(Characters pattern, [int maxParts = 0]) Iterable<CharacterRange>
Splits the current range of characters at each occurrence of pattern.
startsWith(Characters characters) bool
Whether the current range starts with characters.
toString() String
A string representation of this object.
inherited

Operators

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