StringExtensions extension

A set of utility methods for working with strings.

on

Methods

compressSpaces({bool trim = true}) String?

Available on String, provided by the StringExtensions extension

Extension method to remove consecutive spaces in a String and optionally trim the result.
encloseInParentheses({bool wrapEmpty = false}) String?

Available on String, provided by the StringExtensions extension

Extension method to enclose a String in parentheses.
getFirstDiffChar(String other) String

Available on String, provided by the StringExtensions extension

Compares this string with another string character by character and returns the first character that differs between them, or an empty string if the strings are identical up to the length of the shorter string.
nullIfEmpty({bool trimFirst = true}) String?

Available on String, provided by the StringExtensions extension

Checks if a string is empty.
removeConsecutiveSpaces({bool trim = true}) String?

Available on String, provided by the StringExtensions extension

Extension method to remove consecutive spaces in a String and optionally trim the result.
removeStart(String? start, {bool isCaseSensitive = true, bool trimFirst = false}) String?

Available on String, provided by the StringExtensions extension

Returns a new string with the specified start removed from the beginning of the original string, if it exists.
words() List<String>?

Available on String, provided by the StringExtensions extension

Splits the string into a list of words, using space (" ") as the delimiter.
wrapWith({String? before, String? after}) String?

Available on String, provided by the StringExtensions extension

Extension method to wrap a String with a prefix before and a suffix after.