OptionalStringExtension extension
Null-safe helpers on String? (null counts as empty). json["name"].isNullOrEmpty()
- on
Methods
-
formatJalaliDateTime(
) → String -
Available on String?, provided by the OptionalStringExtension extension
ISO date text → local "14:05:09 1403/1/1", or just the date at midnight. -
getPrice(
) → String -
Available on String?, provided by the OptionalStringExtension extension
Groups a whole number with commas, "0" when empty. "1500000" → "1,500,000" -
isNotNullOrEmpty(
) → bool -
Available on String?, provided by the OptionalStringExtension extension
True when it has at least one character. -
isNullOrBlank(
) → bool -
Available on String?, provided by the OptionalStringExtension extension
True when null, "" or only spaces. -
isNullOrEmpty(
) → bool -
Available on String?, provided by the OptionalStringExtension extension
True when null or "". -
isNumeric(
) → bool -
Available on String?, provided by the OptionalStringExtension extension
True when it parses as a number. "3.5" → true -
nullIfEmpty(
) → String? -
Available on String?, provided by the OptionalStringExtension extension
Null when null or "".name.nullIfEmpty() -
number(
) → int -
Available on String?, provided by the OptionalStringExtension extension
The digits as an int (0 when null). "Order #42" → 42 -
numberString(
) → String -
Available on String?, provided by the OptionalStringExtension extension
Digits only ("0" when null). "a1b2" → "12" -
orIfBlank(
String fallback) → String -
Available on String?, provided by the OptionalStringExtension extension
The text, orfallbackwhen null or blank.user.name.orIfBlank("Guest") -
rial(
{bool removeNegative = false}) → String -
Available on String?, provided by the OptionalStringExtension extension
"1500000" → "1,500,000 ریال";removeNegativedrops the minus sign. -
rialToTomanMoneyPersian(
) → String -
Available on String?, provided by the OptionalStringExtension extension
Rial text → toman text (÷10). "150000" → "15,000 تومان" -
separateNumbers3By3(
) → String -
Available on String?, provided by the OptionalStringExtension extension
Puts a comma every 3 digits. "1500000" → "1,500,000" -
toJalaliDate(
) → String -
Available on String?, provided by the OptionalStringExtension extension
ISO date text → "1403/01/01" in Jalali (now when null). -
toJalaliDateString(
) → String -
Available on String?, provided by the OptionalStringExtension extension
ISO date text → long Jalali date (now when null). "2024-03-20" → "چهارشنبه ۱ فروردین ۱۴۰۳" -
toJalaliDateTime(
) → String -
Available on String?, provided by the OptionalStringExtension extension
ISO date text → "1403/01/01 14:05" in Jalali (now when null). -
toman(
{bool removeNegative = false}) → String -
Available on String?, provided by the OptionalStringExtension extension
"1500000" → "1,500,000 تومان";removeNegativedrops the minus sign. -
toStringOrEmptyIfNull(
) → String -
Available on String?, provided by the OptionalStringExtension extension
The text, or "" when null.user.bio.toStringOrEmptyIfNull()