CurrencyAmount class

Exact amount of specific currency.

Example

import 'package:kind/kind.dart';

void main() {
  // 3.14 Danish krones.
  final amount = CurrencyAmount('3.14', Currency.dkk);

  // Prints "3.14 kr"
  print(amount.toLocalFormat());

  // Prints "DKK 3.14"
  print(amount.toCodeFormat());
}
Implemented types

Constructors

CurrencyAmount(String s, Currency currency)
factory
CurrencyAmount.eur(String s)
A shorthand for constructing amounts of Currency.eur.
factory
CurrencyAmount.fromDecimal(Decimal amount, {required Currency currency})
CurrencyAmount.usd(String s)
A shorthand for constructing amounts of Currency.usd.
factory

Properties

amount Decimal
Exact amount.
final
currency Currency
Currency.
final
hashCode int
The hash code for this object.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

compareTo(CurrencyAmount other) int
Compares this object to another object.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
scale(num f) CurrencyAmount
Multiples this amount with a number.
toCodeFormat() String
Constructs a string with format "USD 3.14".
toString() String
A string representation of this object.
override

Operators

operator +(CurrencyAmount other) CurrencyAmount
Adds an amount of the same currency.
operator -(CurrencyAmount other) CurrencyAmount
Subtracts an amount of the same currency.
operator ==(Object other) bool
The equality operator.
override
operator unary-() CurrencyAmount
Negates the amount.

Static Methods

parseCodeFormat(String s) CurrencyAmount
Parses strings with format "USD 3.14".
tryParse(String s, {required Currency currency}) CurrencyAmount?