DHUNullSafeStringExtensions extension

Extensions for nullable String helpers.

on

Properties

clean String?

Available on String?, provided by the DHUNullSafeStringExtensions extension

Removes all whitespace characters and collapses the string into a single line.
no setter
containsDigits bool

Available on String?, provided by the DHUNullSafeStringExtensions extension

Checks if the string contains any digits.
no setter
hasCapitalLetter bool

Available on String?, provided by the DHUNullSafeStringExtensions extension

Checks if the string contains at least one capital letter.
no setter
hasNoSpecialChars bool

Available on String?, provided by the DHUNullSafeStringExtensions extension

Checks if the string does NOT contain any characters that are not letters, numbers, or spaces (i.e., special characters).
no setter
hasSpecialChars bool

Available on String?, provided by the DHUNullSafeStringExtensions extension

Checks if the string contains any characters that are not letters, numbers, or spaces (i.e., special characters).
no setter
isAlphabet bool

Available on String?, provided by the DHUNullSafeStringExtensions extension

Checks if the string consists only of ASCII letters (A-Z, a-z).
no setter
isAlphanumeric bool

Available on String?, provided by the DHUNullSafeStringExtensions extension

Checks if the string contains only letters and numbers.
no setter
isBlank bool

Available on String?, provided by the DHUNullSafeStringExtensions extension

Returns true if the string is null, empty, or solely made of whitespace characters. Alias for isEmptyOrNull.
no setter
isBool bool

Available on String?, provided by the DHUNullSafeStringExtensions extension

Checks if the string is a boolean literal (true/false, case-insensitive).
no setter
isEmptyOrNull bool

Available on String?, provided by the DHUNullSafeStringExtensions extension

Returns true if the string is null, empty, or, after cleaning (collapsing into a single line, removing all whitespaces), is empty.
no setter
isNotBlank bool

Available on String?, provided by the DHUNullSafeStringExtensions extension

Returns true if the string is neither null, empty, nor solely made of whitespace characters. Alias for isNotEmptyOrNull.
no setter
isNotEmptyOrNull bool

Available on String?, provided by the DHUNullSafeStringExtensions extension

Returns true if the string is not null, not empty, and, after cleaning (removing all whitespaces and collapsing into a single line), is not empty.
no setter
isNumeric bool

Available on String?, provided by the DHUNullSafeStringExtensions extension

Checks if the string consists only of ASCII digits (no sign or decimals).
no setter
isPalindrome bool

Available on String?, provided by the DHUNullSafeStringExtensions extension

Checks if the string is a palindrome.
no setter
isUuid bool

Available on String?, provided by the DHUNullSafeStringExtensions extension

Checks if the string is a valid UUID.
no setter
isValidCurrency bool

Available on String?, provided by the DHUNullSafeStringExtensions extension

Checks if the string is a valid currency format.
no setter
isValidEmail bool

Available on String?, provided by the DHUNullSafeStringExtensions extension

Checks if the string is a valid email address.
no setter
isValidHTML bool

Available on String?, provided by the DHUNullSafeStringExtensions extension

Checks if the string is an HTML file or URL.
no setter
isValidIp4 bool

Available on String?, provided by the DHUNullSafeStringExtensions extension

Checks if the string is a valid IPv4 address.
no setter
isValidPhoneNumber bool

Available on String?, provided by the DHUNullSafeStringExtensions extension

Checks if the string is a valid phone number.
no setter
isValidUrl bool

Available on String?, provided by the DHUNullSafeStringExtensions extension

Checks if the string is a valid URL.
no setter
isValidUsername bool

Available on String?, provided by the DHUNullSafeStringExtensions extension

Checks if the string is a valid username.
no setter
lastIndex String

Available on String?, provided by the DHUNullSafeStringExtensions extension

Returns the last character of the string.
no setter
maskEmail String

Available on String?, provided by the DHUNullSafeStringExtensions extension

Masks the email address for privacy. Example: "johndoe@gmail.com" -> "jo****@gmail.com"
no setter
orEmpty String

Available on String?, provided by the DHUNullSafeStringExtensions extension

Returns the string if it is not null, or the empty string otherwise.
no setter
removeWhiteSpaces String?

Available on String?, provided by the DHUNullSafeStringExtensions extension

Removes all whitespace characters (spaces, tabs, newlines, etc.) from the string.
no setter
startsWithNumber bool

Available on String?, provided by the DHUNullSafeStringExtensions extension

Checks if the string starts with a number (digit).
no setter
toOneLine String?

Available on String?, provided by the DHUNullSafeStringExtensions extension

Converts the string into a single line by replacing newline characters.
no setter

Methods

anyChar(bool predicate(String element)) bool

Available on String?, provided by the DHUNullSafeStringExtensions extension

Returns true if at least one character matches the given predicate. The predicate should have only one character.
equalsIgnoreCase(String? other) bool

Available on String?, provided by the DHUNullSafeStringExtensions extension

Compares the current string with another string for equality, ignoring case differences.
hasMatch(String pattern, {bool multiLine = false, bool caseSensitive = true, bool unicode = false, bool dotAll = false}) bool

Available on String?, provided by the DHUNullSafeStringExtensions extension

Helper function to check for pattern matches.
ifEmpty<T>(Future<T> action()) Future<T>?

Available on String?, provided by the DHUNullSafeStringExtensions extension

If the string is empty, performs an action.
insert(int index, String str) String

Available on String?, provided by the DHUNullSafeStringExtensions extension

Returns a new string in which a specified string is inserted at a specified index position in this instance.
limitFromEnd(int maxSize) String?

Available on String?, provided by the DHUNullSafeStringExtensions extension

Shrinks the string to be no more than maxSize in length, extending from the end. Example: In a string with 10 characters, a maxSize of 3 would return the last 3 characters.
limitFromStart(int maxSize) String?

Available on String?, provided by the DHUNullSafeStringExtensions extension

Shrinks the string to be no more than maxSize in length, extending from the start. Example: In a string with 10 characters, a maxSize of 3 would return the first 3 characters.
mask({int visibleStart = 0, int visibleEnd = 0, String char = '*'}) String

Available on String?, provided by the DHUNullSafeStringExtensions extension

Masks the string keeping visibleStart and visibleEnd characters visible.
removeSurrounding(String delimiter) String?

Available on String?, provided by the DHUNullSafeStringExtensions extension

Returns the string only if the delimiter exists at both ends, otherwise returns the current string.
replaceAfter(String delimiter, String replacement, [String? defaultValue]) String?

Available on String?, provided by the DHUNullSafeStringExtensions extension

Replaces part of the string after the first occurrence of the given delimiter with the replacement string. If the string does not contain the delimiter, returns defaultValue which defaults to the original string.
replaceBefore(String delimiter, String replacement, [String? defaultValue]) String?

Available on String?, provided by the DHUNullSafeStringExtensions extension

Replaces part of the string before the first occurrence of the given delimiter with the replacement string. If the string does not contain the delimiter, returns defaultValue which defaults to the original string.
toCharArray() List<String>

Available on String?, provided by the DHUNullSafeStringExtensions extension

Returns a list of characters from the string.
truncate(int length, {String suffix = '...'}) String?

Available on String?, provided by the DHUNullSafeStringExtensions extension

Truncates the string to length and appends suffix if it exceeds the length.
wrapString({int wordCount = 1, bool wrapEach = false, String delimiter = '\n'}) String

Available on String?, provided by the DHUNullSafeStringExtensions extension

Wraps the string based on the specified word count, wrap behavior, and delimiter. Example: "This is a test".wrapString(wrapCount: 2, wrapEach: false) => "This is\na test"