StringWatcherExtension extension
StringWatcherExtension
Extension on Watcher<String>
providing additional String-specific functionalities.
Example:
final StringWatcher = 'hello'.watcher;
print(stringWatcher[0]) // h
Properties
-
codeUnits
→ List<
int> -
An unmodifiable list of the UTF-16 code units of this string.
no setter
- isEmpty → bool
-
Whether this string is empty.
no setter
- isNotEmpty → bool
-
Whether this string is not empty.
no setter
- length → int
-
The length of the string.
no setter
- runes → Runes
-
An Iterable of Unicode code-points of this string.
no setter
Methods
-
codeUnitAt(
int index) → int -
Returns the 16-bit UTF-16 code unit at the given
index
. -
compareTo(
String other) → int -
Compares this string to
other
. -
contains(
Pattern other, [int startIndex = 0]) → bool -
Whether this string contains a match of
other
. -
endsWith(
String other) → bool -
Whether this string ends with
other
. -
indexOf(
Pattern pattern, [int start = 0]) → int -
Returns the position of the first match of
pattern
in this string, starting atstart
, inclusive: -
lastIndexOf(
Pattern pattern, [int? start]) → int -
The starting position of the last match
pattern
in this string. -
padLeft(
int width, [String padding = ' ', bool refresh = true]) → String -
Pads this string on the left if it is shorter than
width
. -
padRight(
int width, [String padding = ' ', bool refresh = true]) → String -
Pads this string on the right if it is shorter than
width
. -
replaceAll(
Pattern from, String replace) → String -
Replaces all substrings that match
from
withreplace
. -
replaceAllMapped(
Pattern from, String replace(Match match)) → String -
Replace all substrings that match
from
by a computed string. -
replaceFirst(
Pattern from, String to, [int startIndex = 0, bool refresh = true]) → String -
Creates a new string with the first occurrence of
from
replaced byto
. -
replaceFirstMapped(
Pattern from, String replace(Match match), [int startIndex = 0, bool refresh = true]) → String -
Replace the first occurrence of
from
in this string. -
replaceRange(
int start, int? end, String replacement) → String -
Replaces the substring from
start
toend
withreplacement
. -
split(
Pattern pattern) → List< String> -
Splits the string at matches of
pattern
and returns a list of substrings. -
splitMapJoin(
Pattern pattern, {String onMatch(Match)?, String onNonMatch(String)?, bool refresh = true}) → String - Splits the string, converts its parts, and combines them into a new string.
-
startsWith(
Pattern pattern, [int index = 0]) → bool -
Whether this string starts with a match of
pattern
. -
substring(
int start, [int? end, bool refresh = true]) → String -
The substring of this string from
start
, inclusive, toend
, exclusive. -
toLowerCase(
) → String - Converts all characters in this string to lower case.
-
toUpperCase(
) → String - Converts all characters in this string to upper case.
-
trim(
) → String - The string without any leading and trailing whitespace.
-
trimLeft(
) → String - The string without any leading whitespace.
-
trimRight(
) → String - The string without any trailing whitespace.
Operators
-
operator *(
int times) → String - Creates a new string by concatenating this string with itself a number of times.
-
operator +(
String other) → String -
Creates a new string by concatenating this string with
other
. -
operator [](
int index) → String -
The character (as a single-code-unit String) at the given
index
.