SuperString extension
String transformations useful for search, display labels and identifiers.
Helpers transform strings; they are not HTML sanitizers, escaping or security validators.
Gallery walkthrough · browser route /#/helpers.
These examples use the current checkout; published 1.x APIs can differ.
Normalize a search term
import 'package:activity/activity.dart';
void main() {
final query = ' Hello Activity '.collapseWhitespace;
assert(query == 'Hello Activity');
assert(query.snakeCase == 'hello_activity');
}
Extract and shorten display text
import 'package:activity/activity.dart';
void main() {
assert('task[id:42]'.between('[', ']') == 'id:42');
assert('A long description'.truncate(8).length == 8);
}
- on
Properties
- camelCase → String
-
Available on String, provided by the SuperString extension
lowerCamelCase shorthand.no setter - collapseWhitespace → String
-
Available on String, provided by the SuperString extension
Collapse all consecutive whitespace to a single space and trim ends.no setter - first → String
-
Available on String, provided by the SuperString extension
First character (code point). Throws StateError if empty.no setter - isAlNum → bool
-
Available on String, provided by the SuperString extension
True if all characters are alphanumeric (letters or digits).no setter - isAlpha → bool
-
Available on String, provided by the SuperString extension
True if all characters are alphabetic letters.no setter - isDouble → bool
-
Available on String, provided by the SuperString extension
True if the entire string is a valid double.no setter - isInt → bool
-
Available on String, provided by the SuperString extension
True if the entire string is a valid int.no setter - isInteger → bool
-
Available on String, provided by the SuperString extension
True if all characters are digits (Unicode numeric).no setter - isLowerCase → bool
-
Available on String, provided by the SuperString extension
True if every character is lowercase OR is a non-letter.no setter - isNumber → bool
-
Available on String, provided by the SuperString extension
Alias kept for backward compatibility (actually checks alphanumeric).no setter - isNumeric → bool
-
Available on String, provided by the SuperString extension
True if the entire string is a valid number (int or double) in Dart sense.no setter - isUpperCase → bool
-
Available on String, provided by the SuperString extension
True if every character is already uppercase OR is a non-letter. (e.g. 'HELLO', '123!?', '' -> true; 'Hello' -> false)no setter -
iterable
→ Iterable<
String> -
Available on String, provided by the SuperString extension
Iterable of (code-point) characters. (Grapheme-safe requires package:characters.)no setter - kebabCase → String
-
Available on String, provided by the SuperString extension
kebab-case / param-case.no setter - last → String
-
Available on String, provided by the SuperString extension
Last character (code point). Throws StateError if empty.no setter - pascalCase → String
-
Available on String, provided by the SuperString extension
UpperCamelCase / PascalCase.no setter - reverse → String
-
Available on String, provided by the SuperString extension
Reverse the string (code points).no setter - slugify → String
-
Available on String, provided by the SuperString extension
Make a URL/filename friendly slug (ascii-ish, lowercase, dash-separated).no setter - snakeCase → String
-
Available on String, provided by the SuperString extension
snake_case.no setter - unquote → String
-
Available on String, provided by the SuperString extension
Remove leading/trailing quotes (single or double) if present.no setter
Methods
-
after(
Pattern pattern) → String -
Available on String, provided by the SuperString extension
Part after the firstpattern; returns empty string if not found. -
between(
Pattern start, Pattern end) → String -
Available on String, provided by the SuperString extension
Text betweenstartandend(first matches). Returns empty if not found. -
capitalize(
) → String -
Available on String, provided by the SuperString extension
Capitalize first letter and lowercase the rest. -
charAt(
int index) → String -
Available on String, provided by the SuperString extension
Character atindex(by code point). -
containsAll(
Iterable< String> values) → bool -
Available on String, provided by the SuperString extension
True if this contains allvalues. -
containsAny(
Iterable< String> values) → bool -
Available on String, provided by the SuperString extension
True if this contains any ofvalues. -
count(
String value, [int start = 0, int? end]) → int -
Available on String, provided by the SuperString extension
Count occurrences ofvaluebetweenstart(inclusive) andend(exclusive). -
removeDiacritics(
) → String -
Available on String, provided by the SuperString extension
Strip common diacritics to ASCII equivalents (best effort). -
repeat(
int times) → String -
Available on String, provided by the SuperString extension
Repeat the stringtimes(>= 0). -
title(
) → String -
Available on String, provided by the SuperString extension
Title case: capitalizes each word separated by whitespace. -
titleFromCamel(
) → String -
Available on String, provided by the SuperString extension
Converts camelCase / PascalCase to Title Case Keeps abbreviations (3+ consecutive capitals) intact -
toCamelCase(
{bool isLowerCamelCase = false}) → String -
Available on String, provided by the SuperString extension
Convert into CamelCase (PascalCase by default). IfisLowerCamelCaseis true, produce lowerCamelCase. -
truncate(
int max, {String ellipsis = '…'}) → String -
Available on String, provided by the SuperString extension
Truncate tomaxchars; appendellipsisif truncated.