StringEx extension

Provides a set of extensions for the core String class.

on

Methods

abbreviate(int maxWidth, {int offset = 0}) String

Available on String, provided by the StringEx extension

Abbreviate a string to maxWidth by truncating the string and adding '...' to then truncated string. If offset is passed then the we begin abbreviating from that index into the string.
equalsIgnoreCase(String? rhs) bool

Available on String, provided by the StringEx extension

Compare two strings ignoring case. If rhs is null then returns false. Returns true, if both are the same, ignoring case.
isAscii() bool

Available on String, provided by the StringEx extension

returns true if the String only contains ascii characters. (0 - 128)
isBlank() bool

Available on String, provided by the StringEx extension

true if the the String is Blank. A string that is zero length or only contains whitespace is considered blank.
isLowerCase() bool

Available on String, provided by the StringEx extension

Returns true if the String does not contain upper case letters.
isNotBlank() bool

Available on String, provided by the StringEx extension

true if the String is not Blank. A string that is zero length or only contains whitespace is considered blank.
isNumeric() bool

Available on String, provided by the StringEx extension

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

Available on String, provided by the StringEx extension

Returns true if the String does not contain any lower case letters.
left(int length, {Pad pad = Pad.none}) String

Available on String, provided by the StringEx extension

Returns the first length characters from the String. If length is longer than the String then the result is padded according to pad.
reverse() String

Available on String, provided by the StringEx extension

Returns a string with reversed order of characters.

Available on String, provided by the StringEx extension

Returns the right 'n' characters from the String.
startsWithLowerCase() bool

Available on String, provided by the StringEx extension

Returns true if the String starts with a lower case character.
startsWithUpperCase() bool

Available on String, provided by the StringEx extension

Returns true if the String starts with an upper case character.
toCamelCase({bool lower = false}) String

Available on String, provided by the StringEx extension

Returns the String in the form "UpperCamelCase" or "lowerCamelCase".
toCapitalised() String

Available on String, provided by the StringEx extension

Returns the String with the first character capitalized.
toEscaped({String encode(int charCode)?}) String

Available on String, provided by the StringEx extension

Returns an escaped string. The following characters are escaped
toPrintable() String

Available on String, provided by the StringEx extension

Returns an escaped string. The following characters are escaped
toProperCase() String

Available on String, provided by the StringEx extension

Converts the String to proper case by capitalising the first letter of each word and forcing all other characters to lower case.
toSnakeCase() String

Available on String, provided by the StringEx extension

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.