compareTo method

  1. @override
int compareTo(
  1. covariant Money other
)
override

The order of the comparisons is:

  1. amount

The two currencies must be the same.

Implementation

@override
int compareTo(covariant Money other) {
  if (currency != other.currency) {
    throw const FormatException(
        'You cannot compare two moneys with different currencies. Before'
        ' comparing, convert one of them.');
  }

  // Last comparison
  final int comparison1 = amount.compareTo(other.amount);
  return comparison1;
}