formatAmountFromDouble method
Converts the double into an integer representation, scaled by scale.
For example, multiplying by 10^scale and truncating decimals.
Returns -1 if parsing fails.
Example:
123.45.formatAmountFromDouble(2); // 12345
12.3.formatAmountFromDouble(0); // 12
Implementation
int formatAmountFromDouble(scale) {
try {
double correctAmount = this * (pow(10, scale));
return int.parse(correctAmount.toStringAsFixed(0));
} catch (e) {
inspect(e);
}
return -1;
}