DHUNullSafeStringExtensions extension
- on
Properties
- asBool → bool
-
Available on String?, provided by the DHUNullSafeStringExtensions extension
Converts the string into a boolean. Returns true if the string is any of these values: "true", "yes", "1", or if the string is a number and greater than 0, false if less than 1. This is also case insensitive.no setter - 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. Example: "f1rstDate" => true, "firstDate" => falseno 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 letters (no whitespace).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 represents a boolean value.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 - isNullOrWhiteSpace → bool
-
Available on String?, provided by the DHUNullSafeStringExtensions extension
Indicates whether the string is null, empty, or consists only of whitespace characters.no setter - isNumeric → bool
-
Available on String?, provided by the DHUNullSafeStringExtensions extension
Checks if the string consists only of numbers (no whitespace).no setter - isPalindrome → bool
-
Available on String?, provided by the DHUNullSafeStringExtensions extension
Checks if the string is a palindrome.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 - isValidIp6 → bool
-
Available on String?, provided by the DHUNullSafeStringExtensions extension
Checks if the string is a valid IPv6 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 - 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) 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 - toDouble → double
-
Available on String?, provided by the DHUNullSafeStringExtensions extension
Parses the string as a double or returns null if it is not a number.no setter - toInt → int
-
Available on String?, provided by the DHUNullSafeStringExtensions extension
Parses the string as an int or returns null if it is not a number.no setter - toNum → num
-
Available on String?, provided by the DHUNullSafeStringExtensions extension
Parses the string as a num or returns null if it is not a number.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 - tryToDouble → double?
-
Available on String?, provided by the DHUNullSafeStringExtensions extension
Parses the string as a double or returns null if it is not a number.no setter - tryToInt → int?
-
Available on String?, provided by the DHUNullSafeStringExtensions extension
Parses the string as an int or returns null if it is not a number.no setter - tryToNum → num?
-
Available on String?, provided by the DHUNullSafeStringExtensions extension
Parses the string as a num or returns null if it is not a number.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 givenpredicate
. Thepredicate
should have only one character. -
decode(
{Object? reviver(Object? key, Object? value)?}) → dynamic -
Available on String?, provided by the DHUNullSafeStringExtensions extension
Decodes the JSON string into a dynamic data structure. Returns the decoded dynamic data structure if the string is non-empty and valid JSON. Returns null if the string is null or empty, or if the string is not a valid JSON format. -
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 caseSensitive = true}) → bool -
Available on String?, provided by the DHUNullSafeStringExtensions extension
-
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 thanmaxSize
in length, extending from the end. Example: In a string with 10 characters, amaxSize
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 thanmaxSize
in length, extending from the start. Example: In a string with 10 characters, amaxSize
of 3 would return the first 3 characters. -
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 thereplacement
string. If the string does not contain the delimiter, returnsdefaultValue
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 thereplacement
string. If the string does not contain the delimiter, returnsdefaultValue
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. -
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"