StringUtils class

String utility functions for common string operations

Constructors

StringUtils()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

capitalizeFirst(String text) String
Capitalize first letter of the string
capitalizeWords(String text) String
Capitalize first letter of each word
countOccurrences(String text, String substring) int
Count occurrences of substring
endsWithAny(String text, List<String> suffixes) bool
Check if string ends with any of the given suffixes
extractEmails(String text) List<String>
Extract email addresses from string
extractNumbers(String text) List<int>
Extract numbers from string
extractUrls(String text) List<String>
Extract URLs from string
formatCurrency(double amount, {String currency = '₹', String locale = 'en_IN'}) String
Format string as currency
generateRandomString(int length, {bool includeNumbers = true, bool includeSymbols = false}) String
Generate random string
isPalindrome(String text, {bool caseSensitive = false}) bool
Check if string is palindrome
maskString(String text, {int visibleStart = 2, int visibleEnd = 2, String maskChar = '*'}) String
Mask sensitive information
removeSpecialCharacters(String text, {bool keepSpaces = true}) String
Remove special characters from string
removeWhitespace(String text) String
Remove all whitespace from string
reverse(String text) String
Reverse a string
startsWithAny(String text, List<String> prefixes) bool
Check if string starts with any of the given prefixes
toCamelCase(String text) String
Convert string to camelCase
toKebabCase(String text) String
Convert string to kebab-case
toSlug(String text) String
Convert string to slug
toSnakeCase(String text) String
Convert string to snake_case
truncate(String text, int maxLength, {String suffix = '...'}) String
Truncate string to specified length