PolyFormatter class

POLY-specific currency formatter that expects all currency to be in nanopoly and converts it to poly (1 POLY = 1,000,000,000 nanopoly). Compact formatters replace groups of zeros with quantity abbreviation suffixes (i.e. K=thousond, M=million, B=billion & T=trillion). The simple formatters group zeros into threes. Decimal digits defaults to 6 places. The currency factory method allows complete customization.

Constructors

PolyFormatter({required NumberFormat formatter})
PolyFormatter.compactCurrency({String? locale = 'en', String? name = poly, String? symbol = symbol, int? decimalDigits = 9})
A number format for compact currency representations, e.g. "P1.2M" instead of "P1,200,000".
factory
PolyFormatter.compactSimpleCurrency({String? locale = 'en', String? name = poly, int? decimalDigits = 9})
A number format for compact currency representations, e.g. "$1.2M" instead of "$1,200,000", and which will automatically determine a currency symbol based on the currency name or the locale. See NumberFormat.simpleCurrency.
factory
PolyFormatter.currency({String? locale = 'en', String? name = poly, String? symbol = symbol, int? decimalDigits = 9, String? customPattern})
Create a NumberFormat that formats using the locale's CURRENCY_PATTERN.
factory
PolyFormatter.simpleCurrency({String? locale = 'en', String? name = poly, int? decimalDigits = 9})
Creates a NumberFormat for currencies, using the simple symbol for the currency if one is available (e.g. $, €), so it should only be used if the short currency symbol will be unambiguous.
factory

Properties

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

Methods

format(PolyAmount poly) → String
Convert nanopoly to poly and format num according to our pattern and return the formatted string.
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

Constants

poly → const String
symbol → const String