operator + method

Money operator +(
  1. Money other
)

Add two Money amounts (must be same currency)

Implementation

Money operator +(Money other) {
  if (currency != other.currency) {
    throw ArgumentError('Cannot add different currencies');
  }
  return Money(amount: amount + other.amount, currency: currency);
}