Money class sealed

Money/Currency model

Available extensions
Annotations
  • @freezed

Constructors

Money({required double amount, @Default.new('USD') String currency})
const
factory
Money.fromJson(Map<String, dynamic> json)
factory

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

convertTo(String newCurrency, {double exchangeRate = 1.0}) Money

Available on Money, provided by the MoneyExtensions extension

Convert to another currency (simplified - would need real exchange rates)
formatted({bool showCurrency = true}) String

Available on Money, provided by the MoneyExtensions extension

Format money as 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 *(double factor) Money

Available on Money, provided by the MoneyExtensions extension

Multiply money by a factor
operator +(Money other) Money

Available on Money, provided by the MoneyExtensions extension

Add two Money amounts (must be same currency)
operator -(Money other) Money

Available on Money, provided by the MoneyExtensions extension

Subtract two Money amounts (must be same currency)
operator /(double divisor) Money

Available on Money, provided by the MoneyExtensions extension

Divide money by a factor
operator ==(Object other) bool
The equality operator.
inherited