StringExtensions extension

on

Properties

capitalize → String

Available on String, provided by the StringExtensions extension

Capitalize first letter
no setter
digitsOnly → String

Available on String, provided by the StringExtensions extension

Extract only digits (handy for phone numbers)
no setter
fromBase64 → String?

Available on String, provided by the StringExtensions extension

Decode base64 string (if valid)
no setter
isNotEmptyOrNull → bool

Available on String, provided by the StringExtensions extension

Check if string is not empty (for convenience)
no setter
isNullOrEmpty → bool

Available on String, provided by the StringExtensions extension

Check if string is null, empty or only whitespace
no setter
isNumeric → bool

Available on String, provided by the StringExtensions extension

Check if string is numeric
no setter
isValidEmail → bool

Available on String, provided by the StringExtensions extension

Check if string is a valid email
no setter
isValidUrl → bool

Available on String, provided by the StringExtensions extension

Check if string is a valid URL
no setter
removeSpaces → String

Available on String, provided by the StringExtensions extension

Remove all spaces
no setter
reversed → String

Available on String, provided by the StringExtensions extension

Reverse the string
no setter
titleCase → String

Available on String, provided by the StringExtensions extension

Capitalize all words
no setter
toBase64 → String

Available on String, provided by the StringExtensions extension

Encode string to base64
no setter
toCamelCase → String

Available on String, provided by the StringExtensions extension

Convert snake_case or kebab-case to camelCase
no setter

Methods

countOccurrences(String substring) → int

Available on String, provided by the StringExtensions extension

Count how many times a substring occurs
ellipsize(int maxLength) → String

Available on String, provided by the StringExtensions extension

Limit string length (adds "..." if too long)
equalsIgnoreCase(String other) → bool

Available on String, provided by the StringExtensions extension

Safe compare ignoring case
safeSubstring(int start, [int? end]) → String

Available on String, provided by the StringExtensions extension

Safe substring (won't throw if string is too short)
surround({String left = '"', String right = '"'}) → String

Available on String, provided by the StringExtensions extension

Surround string with quotes (or custom characters)
toDouble({double fallback = 0.0}) → double

Available on String, provided by the StringExtensions extension

Safe double parsing with fallback
toDoubleOrNull() → double?

Available on String, provided by the StringExtensions extension

Convert to double (returns null if not a valid number)
toInt({int fallback = 0}) → int

Available on String, provided by the StringExtensions extension

Safe int parsing with fallback
toIntOrNull() → int?

Available on String, provided by the StringExtensions extension

Convert to int (returns null if not a valid number)
withPrefix(String prefix) → String

Available on String, provided by the StringExtensions extension

Add a prefix if missing
withSuffix(String suffix) → String

Available on String, provided by the StringExtensions extension

Add a suffix if missing