Calculator constructor
Instantiates a calculator instance.
precision
(optional) the number of fractional digits
to apply in the rounding of cash flow values in the notional currency.
Default is 2, with valid options being 0, 2, 3 and 4
profile
(optional) containing a bespoke collection of cash flows
created manually. Use with caution, and only then if the default
profile builder doesn't handle a specific use case. Be aware that the
precision defined in a bespoke profile takes precedence, hence will
override any precision value passed as an argument to this constructor.
Implementation
Calculator({
int precision = 2,
Profile? profile,
}) {
switch (profile == null ? precision : profile.precision) {
case 0:
case 2:
case 3:
case 4:
_precision = (profile == null) ? precision : profile.precision;
break;
default:
throw Exception('The precision of $precision is unsupported. '
'Valid options are 0, 2, 3 or 4');
}
if (profile == null) {
_isBespokeProfile = false;
} else {
_isBespokeProfile = true;
_profile = profile;
}
_series = [];
}