StringExt extension
Extensions for String class providing utility methods
Provides convenient methods for common string operations including:
- Color conversion from hex strings
- Text formatting (capitalize, title case)
- Validation (email, phone)
- Text manipulation (whitespace removal, truncation)
Usage:
// Color conversion
final color = '#FF5733'.toColor;
// Text formatting
final title = 'hello world'.toTitleCase; // 'Hello World'
final cap = 'hello'.capitalize; // 'Hello'
// Validation
final isValidEmail = 'user@example.com'.isEmail; // true
final isValidPhone = '+1234567890'.isPhone; // true
// Text manipulation
final clean = ' hello world '.removeWhitespace; // 'helloworld'
final short = 'Very long text'.truncate(10); // 'Very long...'
- on
Properties
- capitalize → String
-
Available on String, provided by the StringExt extension
Capitalize first letter of the stringno setter - isEmail → bool
-
Available on String, provided by the StringExt extension
Check if string is a valid email addressno setter - isPhone → bool
-
Available on String, provided by the StringExt extension
Check if string is a valid phone numberno setter - removeWhitespace → String
-
Available on String, provided by the StringExt extension
Remove all whitespace characters from the stringno setter - toColor → Color?
-
Available on String, provided by the StringExt extension
Convert hex string to Colorno setter - toTitleCase → String
-
Available on String, provided by the StringExt extension
Convert string to title caseno setter