TFormatter class
A utility class for formatting various types of data such as dates, currency, and phone numbers.
Constructors
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
-
formatCurrency(
double amount) → String - Formats a numeric amount as currency in USD (default locale: en_US, symbol: $). You can customize the locale and symbol if needed.
-
formatDate(
DateTime? date) → String - Formats a DateTime object to a string in the format 'dd/MM/yyyy'. If no date is provided, it defaults to the current date.
-
formatDateAndTime(
DateTime? date) → String - Formats a DateTime object to a string in the format 'dd/MM/yyyy at hh:mm'. If no date is provided, it defaults to the current date and time.
-
formatPhoneNumber(
String phoneNumber) → String - Formats a 10 or 11-digit phone number into a human-readable format. Example (1234567890) becomes (123) 456-7890.
-
internationalFormatPhoneNumber(
String phoneNumber) → String - Formats a phone number into an international format. Removes non-digit characters and adds the country code with proper spacing. Example: '+11234567890' becomes (+1) 123 45 67 890.