StringExtensions extension
Extensions on String for validation and transformation.
- on
Methods
-
after(
String delimiter) → String -
Available on String, provided by the StringExtensions extension
Part after the first occurrence ofdelimiter, or the whole string if absent. -
before(
String delimiter) → String -
Available on String, provided by the StringExtensions extension
Part before the first occurrence ofdelimiter, or the whole string if absent. -
between(
String start, String end) → String? -
Available on String, provided by the StringExtensions extension
Text betweenstartandend, ornullif markers are missing or out of order. -
capitalize(
) → String -
Available on String, provided by the StringExtensions extension
Capitalizes the first letter of the string. -
collapseWhitespace(
) → String -
Available on String, provided by the StringExtensions extension
Replaces runs of whitespace with a single space, trimming ends. -
containsDigit(
) → bool -
Available on String, provided by the StringExtensions extension
Checks if the string contains at least one digit. -
containsLowercase(
) → bool -
Available on String, provided by the StringExtensions extension
Checks if the string contains at least one lowercase letter. -
containsSpecialCharacter(
) → bool -
Available on String, provided by the StringExtensions extension
Whether the string contains at least one non-alphanumeric character. -
containsUppercase(
) → bool -
Available on String, provided by the StringExtensions extension
Checks if the string contains at least one uppercase letter. -
countOccurrences(
String pattern) → int -
Available on String, provided by the StringExtensions extension
Number of (non-overlapping) occurrences ofpattern. -
initials(
{int max = 2}) → String -
Available on String, provided by the StringExtensions extension
Uppercase initial letters (up tomaxwords), useful for avatars. -
isAlphabetic(
) → bool -
Available on String, provided by the StringExtensions extension
Checks if the string contains only alphabetic characters. -
isAlphanumeric(
) → bool -
Available on String, provided by the StringExtensions extension
Whether the string contains only letters and digits. -
isEmail(
) → bool -
Available on String, provided by the StringExtensions extension
Checks if the string is a valid email. -
isJson(
) → bool -
Available on String, provided by the StringExtensions extension
Whether the string is valid JSON (object or array). -
isNullOrWhiteSpace(
) → bool -
Available on String, provided by the StringExtensions extension
Returns true if the string is null, empty, or contains only whitespace. -
isNumeric(
) → bool -
Available on String, provided by the StringExtensions extension
Returns true if the string contains only numeric characters. -
isPhoneNumber(
) → bool -
Available on String, provided by the StringExtensions extension
Checks if the string is a valid phone number (basic check). -
isStrongPassword(
{int minLength = 8, bool requireUppercase = true, bool requireLowercase = true, bool requireDigit = true, bool requireSpecial = true}) → bool -
Available on String, provided by the StringExtensions extension
Whether the string meets common password strength rules. -
isUrl(
) → bool -
Available on String, provided by the StringExtensions extension
Checks if the string is a valid URL. -
masked(
{int visibleCount = 4, String mask = '*'}) → String -
Available on String, provided by the StringExtensions extension
Masks all but the lastvisibleCountcharacters. -
onlyDigits(
) → String -
Available on String, provided by the StringExtensions extension
Keeps only digit characters. -
removeWhitespace(
) → String -
Available on String, provided by the StringExtensions extension
Removes all whitespace from the string. -
replaceLast(
String from, String to) → String -
Available on String, provided by the StringExtensions extension
Replaces the last occurrence offromwithto. -
reverse(
) → String -
Available on String, provided by the StringExtensions extension
Returns a reversed version of the string. -
slugify(
) → String -
Available on String, provided by the StringExtensions extension
Lowercases, collapses whitespace and non-alphanumerics into single hyphens. -
toBool(
) → bool? -
Available on String, provided by the StringExtensions extension
Parses boolean-ish strings:true/yes/1/y->true,false/no/0/n->false, otherwisenull. -
toCamelCase(
) → String -
Available on String, provided by the StringExtensions extension
Converts tocamelCase. -
toDoubleSafe(
) → double? -
Available on String, provided by the StringExtensions extension
Parses asdouble, ornullif not a valid number. -
toIntSafe(
) → int? -
Available on String, provided by the StringExtensions extension
Parses asint, ornullif not a valid integer. -
toKebabCase(
) → String -
Available on String, provided by the StringExtensions extension
Converts tokebab-case. -
toPascalCase(
) → String -
Available on String, provided by the StringExtensions extension
Converts toPascalCase(Title Case without spaces). -
toSnakeCase(
) → String -
Available on String, provided by the StringExtensions extension
Converts tosnake_case. -
toTitleCase(
) → String -
Available on String, provided by the StringExtensions extension
Converts the string to Title Case. -
truncate(
int maxLength, {String ellipsis = '...'}) → String -
Available on String, provided by the StringExtensions extension
Shortens the string to a specified length with an optional ellipsis. -
withoutDigits(
) → String -
Available on String, provided by the StringExtensions extension
Removes all digit characters.