Characters class abstract

The characters of a string.

A character is a Unicode Grapheme cluster represented by a substring of the original string. The Characters class is an Iterable of those strings. However, unlike most iterables, many of the operations are eager. Since the underlying string is known in its entirety, and is known not to change, operations which select a subset of the elements can be computed eagerly, and in that case the operation returns a new Characters object.

The iterator provided by Characters is a CharacterRange which allows iterating the independent characters in both directions, but which also provides ways to select other ranges of characters in different ways.

Implemented types

Constructors

Characters(String string)
Creates a Characters allowing iteration of the characters of string.
factory

Properties

first String
The first element.
no setterinherited
hashCode int
The hash code of string.
no setteroverride
isEmpty bool
Whether this collection has no elements.
no setterinherited
isNotEmpty bool
Whether this collection has at least one element.
no setterinherited
iterator CharacterRange
Iterator over the characters of this string.
no setteroverride
iteratorAtEnd CharacterRange
Iterator over the characters of this string.
no setter
last String
The last element.
no setterinherited
length int
The number of elements in this Iterable.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
single String
Checks that this iterable has only one element, and returns that element.
no setterinherited
string String
The string to iterate over.
no setter

Methods

any(bool test(String element)) bool
Checks whether any element of this iterable satisfies test.
inherited
cast<R>() Iterable<R>
A view of this iterable as an iterable of R instances.
inherited
characterAt(int position) Characters
Returns the single-character sequence of the positionth character.
contains(covariant String singleCharacterString) bool
Whether singleCharacterString occurs in this sequence of characters.
override
containsAll(Characters other) bool
Whether this sequence of characters contains other as a subsequence.
elementAt(int index) String
Returns the indexth element.
inherited
endsWith(Characters other) bool
Whether this string ends with the characters of other.
every(bool test(String element)) bool
Checks whether every element of this iterable satisfies test.
inherited
expand<T>(Iterable<T> toElements(String element)) Iterable<T>
Expands each element of this Iterable into zero or more elements.
inherited
findFirst(Characters characters) CharacterRange?
Finds the first occurrence of characters in this string.
findLast(Characters characters) CharacterRange?
Finds the last occurrence of characters.
firstWhere(bool test(String element), {String orElse()?}) String
The first element that satisfies the given predicate test.
inherited
fold<T>(T initialValue, T combine(T previousValue, String element)) → T
Reduces a collection to a single value by iteratively combining each element of the collection with an existing value
inherited
followedBy(Iterable<String> other) Iterable<String>
Creates the lazy concatenation of this iterable and other.
inherited
forEach(void action(String element)) → void
Invokes action on each element of this iterable in iteration order.
inherited
getRange(int start, [int? end]) Characters
Eagerly selects the range of characters from start to end.
join([String separator = ""]) String
Converts each element to a String and concatenates the strings.
inherited
lastWhere(bool test(String element), {String orElse()?}) String
The last element that satisfies the given predicate test.
inherited
map<T>(T toElement(String e)) Iterable<T>
The current elements of this iterable modified by toElement.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reduce(String combine(String value, String element)) String
Reduces a collection to a single value by iteratively combining elements of the collection using the provided function.
inherited
replaceAll(Characters pattern, Characters replacement) Characters
Replaces pattern with replacement.
replaceFirst(Characters pattern, Characters replacement) Characters
Replaces the first occurrence of pattern with replacement.
singleWhere(bool test(String element), {String orElse()?}) String
The single element that satisfies test.
inherited
skip(int count) Characters
Eagerly selects all but the first count characters.
override
skipLast(int count) Characters
Eagerly selects all but the last count characters.
skipLastWhile(bool test(String)) Characters
Eagerly selects a leading sequence of characters.
skipWhile(bool test(String)) Characters
Eagerly selects a trailing sequence of characters.
override
split(Characters pattern, [int maxParts = 0]) Iterable<Characters>
Splits this sequence of characters at each occurrence of pattern.
startsWith(Characters other) bool
Whether this string starts with the characters of other.
take(int count) Characters
Eagerly selects the first count characters.
override
takeLast(int count) Characters
Eagerly selects the last count characters.
takeLastWhile(bool test(String)) Characters
Eagerly selects a trailing sequence of characters.
takeWhile(bool test(String)) Characters
Eagerly selects a leading sequence of characters.
override
toList({bool growable = true}) List<String>
Creates a List containing the elements of this Iterable.
inherited
toLowerCase() Characters
The characters of the lower-case version of string.
toSet() Set<String>
Creates a Set containing the same elements as this iterable.
inherited
toString() String
The string content of these characters.
override
toUpperCase() Characters
The characters of the upper-case version of string.
where(bool test(String)) Characters
Eagerly selects a subset of the characters.
override
whereType<T>() Iterable<T>
Creates a new lazy Iterable with all elements that have type T.
inherited

Operators

operator +(Characters other) Characters
The characters of the concatenation of this and other.
operator ==(Object other) bool
Whether other to another Characters with the same string.
override

Constants

empty → const Characters
An empty Characters containing no characters.