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 - capitalize → String
-
Available on String, provided by the StringX extension
Capitalizes only the first character.no setter - fromBase64OrNull → String?
-
Available on String, provided by the StringX extension
Decodes Base64 (standard or URL-safe) back to a UTF-8 string, returningnullwhen the input is not valid Base64 text.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 - isNotBlank → bool
-
Available on String, provided by the StringX extension
Returns true if the string contains non-whitespace characters.no setter - jsonDecodeOrNull → dynamic
-
Available on String, provided by the StringX extension
Decodes JSON, returnsnullon failure instead of throwing.no setter -
lines
→ List<
String> -
Available on String, provided by the StringX extension
Lines split on\n,\r\n, or\r.no setter - normalizeWhitespace → String
-
Available on String, provided by the StringX extension
Collapses internal whitespace runs to a single space and trims the ends.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 - stripHtmlTags → String
-
Available on String, provided by the StringX extension
Removes anything that looks like an HTML/XML tag.no setter - swapCase → String
-
Available on String, provided by the StringX extension
Swaps the case of every character.no setter - toBase64 → String
-
Available on String, provided by the StringX extension
UTF-8 Base64 encoding of this string.no setter - toBool → bool
-
Available on String, provided by the StringX extension
Parses string as boolean ('true'evaluates totrue, elsefalse).no setter - toBoolOrNull → bool?
-
Available on String, provided by the StringX extension
Lenient boolean parsing. Returnsnullwhen the value is not recognizable as a boolean.no setter - toCamelCase → String
-
Available on String, provided by the StringX extension
'Hello World'->'helloWorld'no setter - toDotCase → String
-
Available on String, provided by the StringX extension
'hello world'->'hello.world'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 -
toJsonMapOrNull
→ Map<
String, dynamic> ? -
Available on String, provided by the StringX extension
Parses JSON and returnsMap<String, dynamic>ornullif invalid or not a Map.no setter - toKebabCase → String
-
Available on String, provided by the StringX extension
'Hello World'/'helloWorld'->'hello-world'no setter - toPascalCase → String
-
Available on String, provided by the StringX extension
'hello world'->'HelloWorld'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 -
words
→ List<
String> -
Available on String, provided by the StringX extension
Words split on whitespace, underscores, hyphens, and camelCase boundaries — the same tokenizer the case converters use.no setter
Methods
-
charAtOrNull(
int index) → String? -
Available on String, provided by the StringX extension
The character atindex, ornullwhen out of range. -
chunked(
int size) → List< String> -
Available on String, provided by the StringX extension
Splits into consecutive pieces of at mostsizecharacters. -
countOccurrences(
String pattern) → int -
Available on String, provided by the StringX extension
Counts non-overlapping occurrences ofpattern. -
endsWithIgnoreCase(
String other) → bool -
Available on String, provided by the StringX extension
Case-insensitive String.endsWith. -
ensurePrefix(
String prefix) → String -
Available on String, provided by the StringX extension
Prependsprefixunless it is already there. -
ensureSuffix(
String suffix) → String -
Available on String, provided by the StringX extension
Appendssuffixunless it is already there. -
equalsIgnoreCase(
String other) → bool - Case-insensitive equality.
-
hasLengthBetween(
int min, int max) → bool -
Available on String, provided by the StringX extension
Passes if length falls within [min,max] after trimming. -
indent(
int spaces, {String? prefix}) → String -
Available on String, provided by the StringX extension
Prefixes every line withspacesspaces (or a customprefix). -
initials(
{int max = 2}) → String -
Available on String, provided by the StringX extension
Up tomaxuppercase initials taken from the leading words. -
levenshteinDistance(
String other) → int -
Available on String, provided by the StringX extension
Levenshtein edit distance toother. -
mask(
{int unmaskedStart = 0, int unmaskedEnd = 0, String maskChar = '*'}) → String -
Available on String, provided by the StringX extension
Masks characters withmaskChar, preservingunmaskedStartcharacters at the beginning andunmaskedEndcharacters at the end. -
padCenter(
int width, [String padChar = ' ']) → String -
Available on String, provided by the StringX extension
Pads both sides so the result iswidthcharacters wide. -
removePrefix(
String prefix) → String -
Available on String, provided by the StringX extension
Removesprefixif present at the start of this string. -
removeSuffix(
String suffix) → String -
Available on String, provided by the StringX extension
Removessuffixif present at the end of this string. -
repeat(
int count) → String -
Available on String, provided by the StringX extension
Repeats this stringcounttimes. -
similarityTo(
String other) → double -
Available on String, provided by the StringX extension
Similarity tootherin[0, 1], derived from levenshteinDistance. -
startsWithIgnoreCase(
String other) → bool -
Available on String, provided by the StringX extension
Case-insensitive String.startsWith. -
substringSafe(
int start, [int? end]) → String -
Available on String, provided by the StringX extension
String.substring that clamps out-of-range bounds instead of throwing. -
toDuration(
) → Duration -
Available on String, provided by the StringX extension
Parses"SS","MM:SS", or"HH:MM:SS"into a Duration. -
trimHyphens(
) → String - Removes leading and trailing hyphens.
-
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).