toPercent method
Formats this number as a percentage string.
The input is interpreted as a ratio (e.g. 0.1234 → 12.34%).
digits controls the number of fractional digits (default: 2).
If multiply is true (default), the value is multiplied by 100.
0.1234.toPercent(); // "12.34%"
12.34.toPercent(multiply: false); // "12.34%"
0.5.toPercent(digits: 0); // "50%"
Implementation
String toPercent({int digits = 2, bool multiply = true}) {
final value = multiply ? this * 100 : this;
return '${value.toStringAsFixed(digits)}%';
}