StringExtensions extension
Everyday String helpers: numbers, money, Persian digits, dates, file names, validation, encodings. "۱۲۳".toLatinNumber()
- on
Properties
- fileExtension → String
-
Available on String, provided by the StringExtensions extension
Extension with the dot. "a/b.pdf" → ".pdf"no setter - fileName → String
-
Available on String, provided by the StringExtensions extension
Last part of a path or URL, without ?query or #hash. "https://x.com/a/b.pdf?x=1" → "b.pdf"no setter - fileNameWithoutExtension → String
-
Available on String, provided by the StringExtensions extension
File name without its extension. "a/b.tar.gz" → "b.tar"no setter - hasPersian → bool
-
Available on String, provided by the StringExtensions extension
True when the text contains any Persian letter.no setter - isAlphanumeric → bool
-
Available on String, provided by the StringExtensions extension
True when only English letters and digits.no setter - isBlank → bool
-
Available on String, provided by the StringExtensions extension
True when empty or only spaces.no setter - isPersian → bool
-
Available on String, provided by the StringExtensions extension
True when the text is written in Persian letters. "سلام".isPersian → trueno setter - isStrongPassword → bool
-
Available on String, provided by the StringExtensions extension
True for 8+ chars with upper, lower, digit and one of @$!%*?&.no setter - isValidEmail → bool
-
Available on String, provided by the StringExtensions extension
True for a valid email address.no setter - isValidPhone → bool
-
Available on String, provided by the StringExtensions extension
True for 8-15 digits with optional + (Latin digits only; call toLatinNumber() first).no setter - isValidUrl → bool
-
Available on String, provided by the StringExtensions extension
True for a web address (http/https optional).no setter - reversed → String
-
Available on String, provided by the StringExtensions extension
The text reversed (emoji safe). "abc" → "cba"no setter
Methods
-
append0(
) → String -
Available on String, provided by the StringExtensions extension
Adds a leading zero to a single character. "5" → "05" -
capitalize(
) → String -
Available on String, provided by the StringExtensions extension
First letter upper-case. "hello" → "Hello" -
countOf(
String other) → int -
Available on String, provided by the StringExtensions extension
Number of timesotherappears."banana".countOf("a")→ 3 -
englishDay(
) → String -
Available on String, provided by the StringExtensions extension
Persian weekday names (with space, half-space or joined) → English. "دوشنبه" → "Monday" -
englishMonth(
) → String -
Available on String, provided by the StringExtensions extension
Two-digit month numbers → English month names. "01" → "January" -
extractLatinNumber(
) → String -
Available on String, provided by the StringExtensions extension
Digits only, Persian digits converted first. "۱۲-۳" → "123" -
formatJalaliDateTime(
) → String -
Available on String, provided by the StringExtensions extension
ISO date → "1403/1/1 14:05:09" in Jalali. -
fromBase58(
) → String -
Available on String, provided by the StringExtensions extension
Base58 → text; throws FormatException on a bad character. -
fromBase64(
) → String -
Available on String, provided by the StringExtensions extension
Base64 → text. "aGk=" → "hi" -
getDay(
) → int -
Available on String, provided by the StringExtensions extension
Day from an ISO date. "2024-03-20" → 20 -
getHour(
) → int -
Available on String, provided by the StringExtensions extension
Hour from "HH:mm". "14:05" → 14 -
getMinute(
) → int -
Available on String, provided by the StringExtensions extension
Minute from "HH:mm". "14:05" → 5 -
getMonth(
) → int -
Available on String, provided by the StringExtensions extension
Month from an ISO date. "2024-03-20" → 3 -
getYear(
) → int -
Available on String, provided by the StringExtensions extension
Year from an ISO date. "2024-03-20" → 2024 -
isFalse(
) → bool -
Available on String, provided by the StringExtensions extension
True for "false" (any case). -
isNumeric(
) → bool -
Available on String, provided by the StringExtensions extension
True when it parses as a number. "3.5" → true -
isTrue(
) → bool -
Available on String, provided by the StringExtensions extension
True for "true" (any case). -
mask(
{int start = 4, int end = 4, String char = "*"}) → String -
Available on String, provided by the StringExtensions extension
Hides the middle withchar, keepingstartandendcharacters. "09121234567".mask(start: 4, end: 3) → "0912****567" -
maxLength(
{required int max}) → String -
Available on String, provided by the StringExtensions extension
Cuts tomaxcharacters with "..." at the end."Hello world".maxLength(max: 8)→ "Hello..." -
normalizePersian(
) → String -
Available on String, provided by the StringExtensions extension
Arabic ي/ك → Persian ی/ک and removes tatweel (ـ), for search and saving. "علي" → "علی" -
nullIfEmpty(
) → String? -
Available on String, provided by the StringExtensions extension
Null when "".name.nullIfEmpty() -
number(
) → int -
Available on String, provided by the StringExtensions extension
The digits as an int. "Order #42" → 42 -
numberString(
) → String -
Available on String, provided by the StringExtensions extension
Digits only. "a1-b2" → "12" -
persianDayDay(
) → String -
Available on String, provided by the StringExtensions extension
English weekday names → Persian. "Monday" → "دو شنبه" -
persianMonth(
) → String -
Available on String, provided by the StringExtensions extension
Two-digit month numbers → Jalali month names. "01" → "فروردین" -
removeCharAt(
int charIndex) → String -
Available on String, provided by the StringExtensions extension
Removes the character atcharIndex."abc".removeCharAt(1)→ "ac" -
rial(
) → String -
Available on String, provided by the StringExtensions extension
"1500000" → "1,500,000 ریال " -
separateCharacters(
int number, String separator) → String -
Available on String, provided by the StringExtensions extension
Putsseparatoreverynumberdigits from the right."1234567".separateCharacters(3, "٬") -
separateNumbers3By3(
) → String -
Available on String, provided by the StringExtensions extension
Puts a comma every 3 digits. "1500000" → "1,500,000" -
subStringIfExist(
int start, int end) → String -
Available on String, provided by the StringExtensions extension
substring(start, end) that returns the whole text when it is shorter thanend."hello".subStringIfExist(0, 3)→ "hel" -
toBase58(
) → String -
Available on String, provided by the StringExtensions extension
Text → Base58 (Bitcoin alphabet). -
toBase64(
) → String -
Available on String, provided by the StringExtensions extension
Text → base64. "hi" → "aGk=" -
toBytesFromBase64(
) → Uint8List -
Available on String, provided by the StringExtensions extension
Base64 text → bytes.imageBase64.toBytesFromBase64() -
toBytesFromBase64Url(
) → Uint8List -
Available on String, provided by the StringExtensions extension
URL-safe base64 text → bytes. -
toColor(
) → Color -
Available on String, provided by the StringExtensions extension
Hex color text → Color; accepts "#RGB", "#RRGGBB" and "#AARRGGBB". "#FF5722".toColor() -
toDateTime(
) → DateTime? -
Available on String, provided by the StringExtensions extension
Parses an ISO date, null when it is not one. "2024-03-20".toDateTime() -
toDouble(
) → double -
Available on String, provided by the StringExtensions extension
Parses a double, 0 when it is not one. "3.5" → 3.5 -
toDoubleOrNull(
) → double? -
Available on String, provided by the StringExtensions extension
Parses a double, null when it is not one. -
toInt(
) → int -
Available on String, provided by the StringExtensions extension
Parses an int, 0 when it is not one. "42" → 42 -
toIntOrNull(
) → int? -
Available on String, provided by the StringExtensions extension
Parses an int, null when it is not one. "x".toIntOrNull() → null -
toJalaliCompactDateString(
) → String -
Available on String, provided by the StringExtensions extension
ISO date → "1403/01/01". -
toJalaliDateString(
) → String -
Available on String, provided by the StringExtensions extension
ISO date → long Jalali date with weekday and month name. -
toLatinNumber(
) → String -
Available on String, provided by the StringExtensions extension
Any digits (Persian, Arabic, Hindi, full-width…) → Latin digits. "۱۲۳" → "123" -
toman(
) → String -
Available on String, provided by the StringExtensions extension
"1500000" → "1,500,000 تومان " -
toPersianNumber(
) → String -
Available on String, provided by the StringExtensions extension
Latin digits → Persian digits. "123" → "۱۲۳" -
toSlug(
) → String -
Available on String, provided by the StringExtensions extension
URL-friendly slug (Persian letters kept). "Hello World!" → "hello-world" -
toTimeAgo(
{bool numericDates = false, bool persian = false}) → String -
Available on String, provided by the StringExtensions extension
ISO date → "3 hours ago" / "۳ ساعت پیش"; older than 8 days shows the date.createdAt.toTimeAgo(persian: true) -
toTitleCase(
) → String -
Available on String, provided by the StringExtensions extension
Every word capitalized. "hello big world" → "Hello Big World"