whoseMethodWas method
List<MoneyTransaction>
whoseMethodWas({
- Currency? currency,
- List<
ExchangeRate> ? exchangeRates, - required MoneyTransactionMethod method,
- bool normalized = false,
Returns a filtered list of all the transactions in whose method was
method
. The result is already sorted.
If a normalized list is expected as a result, it is possible to set
normalized
equal to true
. In this case, the currency
parameter must
also be specified, otherwise a FormatException
will be thrown. The
exchangeRates
parameter is also expected to be specified.
Implementation
List<MoneyTransaction> whoseMethodWas({
Currency? currency,
List<ExchangeRate>? exchangeRates,
required MoneyTransactionMethod method,
bool normalized = false,
}) {
if (normalized && currency == null) {
throw const FormatException(
'whoseMethodWas: You cannot normalize a list without specifying the'
' currency against which you want to normalize it.');
}
final result =
where((moneyTransaction) => moneyTransaction.method == method).toList()
..sort();
if (normalized && currency != null) {
return result.normalize(
currency: currency,
exchangeRates: exchangeRates,
);
}
return result;
}