StringX extension
Main extension on String providing comprehensive conversion and formatting tools.
- on
Properties
- blankToNull → String?
-
Available on String, provided by the StringX extension
Returnsnullif blank, otherwisethis. Useful for form validation chains.no setter - isAlpha → bool
-
Available on String, provided by the StringX extension
Returns true if the string only contains letters.no setter - isAlphanumeric → bool
-
Available on String, provided by the StringX extension
Returns true if the string only contains letters and numbers.no setter - isBlank → bool
-
Available on String, provided by the StringX extension
Returns true if the string is purely whitespace or empty.no setter - isEmail → bool
-
Available on String, provided by the StringX extension
Returns true if the string is a valid email format.no setter - isNotBlank → bool
-
Available on String, provided by the StringX extension
Returns true if the string contains non-whitespace characters.no setter - isNumeric → bool
-
Available on String, provided by the StringX extension
Returns true if the string represents a valid number.no setter - isUrl → bool
-
Available on String, provided by the StringX extension
Returns true if the string is a valid URL.no setter - jsonDecodeOrNull → dynamic
-
Available on String, provided by the StringX extension
Decodes JSON, returnsnullon failure instead of throwing.no setter - readingTimeMinutes → int
-
Available on String, provided by the StringX extension
Estimates the reading time in minutes (225 words per minute).no setter - removeWhitespace → String
-
Available on String, provided by the StringX extension
Removes all whitespace, including internal.no setter - reversed → String
-
Available on String, provided by the StringX extension
Reverses the string (Unicode-safe via runes).no setter - toBool → bool
-
Available on String, provided by the StringX extension
Parses string as boolean ('true'evaluates totrue, elsefalse).no setter - toCamelCase → String
-
Available on String, provided by the StringX extension
'Hello World'→'helloWorld'no setter - toDoubleOrNull → double?
-
Available on String, provided by the StringX extension
Parses to double, returnsnullon failure.no setter - toDoubleOrZero → double
-
Available on String, provided by the StringX extension
Parses to double, returns0.0on failure.no setter - toDurationOrNull → Duration?
-
Available on String, provided by the StringX extension
Parses"SS","MM:SS", or"HH:MM:SS"into a Duration, returns null on failure.no setter - toIntOrNull → int?
-
Available on String, provided by the StringX extension
Parses to int, returnsnullon failure.no setter - toIntOrZero → int
-
Available on String, provided by the StringX extension
Parses to int, returns0on failure.no setter - toKebabCase → String
-
Available on String, provided by the StringX extension
'Hello World'/'helloWorld'→'hello-world'no setter - toScreamingSnakeCase → String
-
Available on String, provided by the StringX extension
'hello world'→'HELLO_WORLD'no setter - toSentenceCase → String
-
Available on String, provided by the StringX extension
Capitalizes only the first character.no setter - toSlug → String
-
Available on String, provided by the StringX extension
URL-safe slug: lowercased, spaces→hyphens, non-alphanumeric stripped.'Hello World! 2024'→'hello-world-2024'no setter - toSnakeCase → String
-
Available on String, provided by the StringX extension
'Hello World'/'helloWorld'→'hello_world'no setter - toTitleCase → String
-
Available on String, provided by the StringX extension
Capitalizes the first letter of each whitespace-delimited word.no setter - toUriOrNull → Uri?
-
Available on String, provided by the StringX extension
Parses string to Uri, returnsnullon failure.no setter
Methods
-
countOccurrences(
String pattern) → int -
Available on String, provided by the StringX extension
Counts non-overlapping occurrences ofpattern. -
hasLengthBetween(
int min, int max) → bool -
Available on String, provided by the StringX extension
Passes if length falls within [min,max] after trimming. -
repeat(
int count) → String -
Available on String, provided by the StringX extension
Repeats this stringcounttimes. -
toDuration(
) → Duration -
Available on String, provided by the StringX extension
Parses"SS","MM:SS", or"HH:MM:SS"into a Duration. -
truncate(
int maxLength, {String ellipsis = '...'}) → String -
Available on String, provided by the StringX extension
Truncates tomaxLengthchars, appendingellipsisif cut. -
truncateWords(
int maxLength, {String ellipsis = '...'}) → String - Truncates at a word boundary instead of mid-word.
-
wrap(
String prefix, [String? suffix]) → String -
Available on String, provided by the StringX extension
Wraps the string withprefixandsuffix(defaults toprefix).