StringEx extension
Provides a set of extensions for the core String class.
- on
Methods
-
abbreviate(
int maxWidth, {int offset = 0}) → String -
Abbreviate a string to
maxWidth
by truncating the string and adding '...' to then truncated string. Ifoffset
is passed then the we begin abbreviating from that index into the string. -
equalsIgnoreCase(
String? rhs) → bool - Compare two strings ignoring case. If rhs is null then returns false. Returns true, if both are the same, ignoring case.
-
isAscii(
) → bool - returns true if the String only contains ascii characters. (0 - 128)
-
isBlank(
) → bool - true if the the String is Blank. A string that is zero length or only contains whitespace is considered blank.
-
isLowerCase(
) → bool - Returns true if the String does not contain upper case letters.
-
isNotBlank(
) → bool - true if the String is not Blank. A string that is zero length or only contains whitespace is considered blank.
-
isNumeric(
) → bool - Checks if the String is a number by attempting to parse it as a double. INFINITY and NaN are not treated as numbers.
-
isUpperCase(
) → bool - Returns true if the String does not contain any lower case letters.
-
left(
int length, {Pad pad = Pad.none}) → String -
Returns the first
length
characters from the String. Iflength
is longer than the String then the result is padded according topad
. -
reverse(
) → String - Returns a string with reversed order of characters.
-
right(
int length, {Pad pad = Pad.none}) → String - Returns the right 'n' characters from the String.
-
startsWithLowerCase(
) → bool - Returns true if the String starts with a lower case character.
-
startsWithUpperCase(
) → bool - Returns true if the String starts with an upper case character.
-
toCamelCase(
{bool lower = false}) → String - Returns the String in the form "UpperCamelCase" or "lowerCamelCase".
-
toCapitalised(
) → String - Returns the String with the first character capitalized.
-
toEscaped(
{String encode(int charCode)?}) → String - Returns an escaped string. The following characters are escaped
-
toPrintable(
) → String - Returns an escaped string. The following characters are escaped
-
toProperCase(
) → String - Converts the String to proper case by capitalising the first letter of each word and forcing all other characters to lower case.
-
toSnakeCase(
) → String - Converts the String to snake_case by inserting an underscore before each sequence of upper case letters and changing all upper case letters to lowercase.