Denomination.fromValue constructor
Denomination.fromValue(
- num value, [
- Denomination? max
Returns a Denomination based on the size of value
.
If a max
Denomination is provided, will not return a denomination
larger than max
.
Implementation
factory Denomination.fromValue(num value, [Denomination? max]) {
if (value < Thousands.minValue || max == Hundreds) {
return Hundreds;
} else if (value < Millions.minValue || max == Thousands) {
return Thousands;
} else if (value < Billions.minValue || max == Millions) {
return Millions;
} else if (value < Trillions.minValue || max == Billions) {
return Billions;
} else {
return Trillions;
}
}