utils/format library

Constants

kDefaultImageBase64 → const String
Base64 encoded string of the default image.

Properties

kCurrencyFormatter → NumberFormat
Number format that displays currency in the South African locale with the symbol "R".
final
kCurrencyFormatterNoCents → NumberFormat
Number format that displays currency in the South African locale with the symbol "R" and no decimal digits.
final
kDateDayFormat → DateFormat
Date format that displays the full day name, day of the month, full month name, and year.
final
kDateFormat → DateFormat
Date format that displays the year, month, and day.
final
kDateTimeFormat → DateFormat
Date and time format that displays the year, month, day, hour, and minute.
final
kPercentFormatter → NumberFormat
Number format that displays percentages in the South African locale.
final

Functions

formatCurrency(double? value) String
Formats a double value to a currency string using the kCurrencyFormatter. Returns 'n/a' if the value is null.
formatDate(DateTime? value) String
Formats a DateTime object to a string using the kDateFormat. Returns 'n/a' if the value is null or represents an invalid date.
formatDateDay(DateTime? value) String
Formats a DateTime object to a string using the kDateDayFormat. Returns 'n/a' if the value is null or represents an invalid date and time.
formatDateTime(DateTime? value) String
Formats a DateTime object to a string using the kDateTimeFormat. Returns 'n/a' if the value is null or represents an invalid date and time.
formatImage(String? imageData) Uint8List
Decodes a base64 encoded string imageData to a Uint8List. If the input is null or empty, it uses kDefaultImageBase64.
formatInitials(String? value) String
Formats a string value to its initials. Returns the first two initials of the input string. If the input is null or empty, returns 'n/a'.
formatNullable(Object? value) String
Converts an Object to a string. Returns 'n/a' if the value is null.
formatNumber(int? value) String
Converts an int value to a string. Returns 'n/a' if the value is null.
formatPercent(double? value) String
Formats a double value to a percentage string using the kPercentFormatter. Returns 'n/a' if the value is null.