StringExtension extension
Provides convenient methods and properties for String.
- on
Properties
-
extractEmails
→ List<
String> -
Available on String, provided by the StringExtension extension
Extracts all email addresses from textno setter -
Available on String, provided by the StringExtension extension
Extracts hashtags from textno setter - isAlpha → bool
-
Available on String, provided by the StringExtension extension
Checks if string contains only alphabetic charactersno setter - isAlphanumeric → bool
-
Available on String, provided by the StringExtension extension
Checks if string contains only alphanumeric charactersno setter - isNumeric → bool
-
Available on String, provided by the StringExtension extension
Returns true if the string contains only digits.no setter - isOnlyWhiteSpace → bool
-
Available on String, provided by the StringExtension extension
This primarily checks if the trimmed string is empty.no setter - isPalindrome → bool
-
Available on String, provided by the StringExtension extension
Checks if string is a palindrome (reads the same forwards and backwards)no setter - isValidEmail → bool
-
Available on String, provided by the StringExtension extension
Returns true if the string is a valid email format. Note: This is a basic regex check. For robust validation, consider a dedicated package.no setter - isValidUrl → bool
-
Available on String, provided by the StringExtension extension
Returns true if the string is a valid URL format. Note: This is a basic check. For robust validation, consider a dedicated package.no setter - wordCount → int
-
Available on String, provided by the StringExtension extension
Gets the count of words in a stringno setter
Methods
-
capitalize(
) → String -
Available on String, provided by the StringExtension extension
Returns the string with the first character capitalized. -
capitalizeWords(
) → String -
Available on String, provided by the StringExtension extension
Returns the string with the first character of each word capitalized. -
charAt(
int index) → String? -
Available on String, provided by the StringExtension extension
Safely accesses a character by index, returns null if index is out of bounds -
containsIgnoreCase(
String other) → bool -
Available on String, provided by the StringExtension extension
Returns true if the string contains the givenother
string, ignoring case. -
countOccurrences(
String substring) → int -
Available on String, provided by the StringExtension extension
Counts occurrences of a substring within the string -
endsWithIgnoreCase(
String other) → bool -
Available on String, provided by the StringExtension extension
Returns true if the string ends with the givenother
string, ignoring case. -
formatAsPhoneNumber(
) → String -
Available on String, provided by the StringExtension extension
Formats string as a phone number based on length -
fromBase64(
) → String -
Available on String, provided by the StringExtension extension
Decodes the string from Base64. -
mask(
int keepStart, int keepEnd, [String maskChar = '*']) → String -
Available on String, provided by the StringExtension extension
Masks a portion of the string, useful for sensitive data -
removeAllWhitespace(
) → String -
Available on String, provided by the StringExtension extension
Returns the string with all whitespace characters removed. -
removeSpecialCharacters(
) → String -
Available on String, provided by the StringExtension extension
Removes special characters from string, leaving only alphanumeric characters and spaces -
repeat(
int count) → String -
Available on String, provided by the StringExtension extension
Repeats the stringcount
times. -
reverse(
) → String -
Available on String, provided by the StringExtension extension
Returns the string reversed. -
startsWithIgnoreCase(
String other) → bool -
Available on String, provided by the StringExtension extension
Returns true if the string starts with the givenother
string, ignoring case. -
toBase64(
) → String -
Available on String, provided by the StringExtension extension
Encodes the string to Base64. -
toCamelCase(
) → String -
Available on String, provided by the StringExtension extension
Converts the string to camelCase (e.g., "hello world" -> "helloWorld"). -
toKebabCase(
) → String -
Available on String, provided by the StringExtension extension
Converts the string to kebab-case (e.g., "Hello World" -> "hello-world"). -
toPascalCase(
) → String -
Available on String, provided by the StringExtension extension
Converts the string to PascalCase (e.g., "hello world" -> "HelloWorld"). -
toSentenceCase(
) → String -
Available on String, provided by the StringExtension extension
Converts the string to sentence case (e.g., "hello world" -> "Hello world"). -
toSlug(
) → String -
Available on String, provided by the StringExtension extension
Converts a string into a URL-friendly slug -
toSnakeCase(
) → String -
Available on String, provided by the StringExtension extension
Converts the string to snake_case (e.g., "Hello World" -> "hello_world"). -
toTitleCase(
) → String -
Available on String, provided by the StringExtension extension
Converts string to proper title case handling articles, conjunctions, and prepositions -
truncate(
int maxLength, {String ellipsis = '...'}) → String -
Available on String, provided by the StringExtension extension
Returns the string truncated to a specified length, optionally adding ellipsis. -
tryDouble(
) → double? -
Available on String, provided by the StringExtension extension
Parses the string as a double. Returns null if parsing fails. -
tryInt(
) → int? -
Available on String, provided by the StringExtension extension
Parses the string as an integer. Returns null if parsing fails.