money2
Search…
Comparison
Equality operator (==) returns true when both operands are in the same currency and have an equal amount.
1
import 'package:money2/money2.dart';
2
fiveDollars == fiveDollars; // => true
3
fiveDollars == sevenDollars; // => false
4
fiveDollars == fiveEuros; // => false (different currencies)
Copied!
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.
1
import 'package:money2/money2.dart';
2
fiveDollars < sevenDollars; // => true
3
fiveDollars > sevenDollars; // => false
4
fiveEuros < fiveDollars; // throws ArgumentError!
Copied!
Copy link