toPercentage method

String toPercentage({
  1. int fractionDigits = 2,
})

Attempts to parse the string as a number and converts it to a percentage string. If the value is greater than 1, it is capped at 100%.

Example:

print('0.1234'.toPercentage()); // 12.34%
print('1.2'.toPercentage()); // 100.00%

Implementation

String toPercentage({int fractionDigits = 2}) =>
    toDecimal.toPercentage(fractionDigits: fractionDigits);