TFormatter class

A helper class containing standard formatting utilities for numbers, distances, currencies, contact numbers, date-times, and ranges.

Constructors

TFormatter()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

cents(num? centsVal, [int decimals = 2, String symbol = "\$"]) String
Formats cents value into currency representation.
currency(double amount, {bool? showSymbol, bool? showDecimals, String? unitSymbol}) String
Formats currency values (defaulting to the en_LK locale, e.g. Rs. 1,000.00).
date(DateTime date) String
Format date
dateTime(DateTime dateTime) String
Format datetime
dollars(num? dollarsVal, [int decimals = 2, String symbol = "\$"]) String
Formats dollars value into currency representation.
duration(DateTime start, DateTime end) String
Formats duration string representing difference between two dates.
fileSize(int bytes) String
Formats file size in bytes to a human-readable format (e.g., "12.5 MB").
formatContactNumber(String? phone) String
Formats contact numbers, normalising '+61' to '0' and spacing 10-digit numbers.
meters(num? metersVal, [int decimals = 1]) String
Formats meters into metric distance (e.g., "1km 200m" or "500m").
metersPerSecond(num? speed) String
Formats speed in meters per second to km/h representation.
minutes(num? mins) String
Formats raw minutes into a human-readable duration.
number(num value, {int decimals = 0}) String
Formats value using a standard decimal format with a configurable number of decimals.
parseDate(String input, {String format = 'YYYY-MM-DD'}) DateTime?
parseUtcISO(String input) DateTime?
percentage(double value, {int decimals = 1}) String
Formats value (e.g. 0.15) to its percentage representation (e.g. "15.0%").
seconds(num? secs) String
Formats raw seconds into a human-readable duration (e.g. "1d 2h 3m 4s").
time(DateTime time) String
Format time
validateDateTime(String dateTime, [int minYear = 1900]) String?
Validates standard ISO date strings, ensuring they are valid and exceed minYear.