money2
  • Overview
  • Common Currencies
  • Creating a Currency
  • Registering a Currency
  • Parsing
  • Find a currency
  • Default format
  • Symbols
  • Separators
    • Decimal Separator
    • Group Separator
  • Creating Money
    • Money.parse
    • Currency.parse
    • Money.from
    • Currencies.parse
    • decimalDigits
  • Formatting
    • Formatting Patterns
  • Storing and Send
  • Exchange Rates
  • Comparison
  • Currency Predicates
  • Value Sign Predicates
  • Arithmetic Operations
  • Allocation
  • Money encoding/decoding
Powered by GitBook
On this page

Was this helpful?

Comparison

Equality operator (==) returns true when both operands are in the same currency and have an equal amount.

import 'package:money2/money2.dart';
fiveDollars == fiveDollars;  // => true
fiveDollars == sevenDollars; // => false
fiveDollars == fiveEuros;    // => false (different currencies)

Money values can be compared with the <, <=, >, >= operators, or the method compareTo() from the interface Comparable<Money>.

These operators and method compareTo() can be used only between money values in the same currency. Runtime error will be thrown on any attempt to compare values in different currencies.

import 'package:money2/money2.dart';
fiveDollars < sevenDollars; // => true
fiveDollars > sevenDollars; // => false
fiveEuros < fiveDollars;    // throws ArgumentError!
PreviousExchange RatesNextCurrency Predicates

Last updated 1 month ago

Was this helpful?