doubleConvert method
The function doubleConvert takes a double value representing a volume and returns a string
representation of the volume as a percentage.
Args: volume (double): The volume parameter is a double value representing a volume measurement.
Returns:
a string representation of the input volume as a percentage. If the volume is equal to 0.05, it
returns '5%'. If the volume is equal to 1.0, it returns '100%'. For any other volume value, it
converts the volume to a string with two decimal places using toStringAsPrecision(2), removes the
decimal point using `
Implementation
String doubleConvert(double volume) {
if (volume == 0.05) {
return '5%';
} else if (volume == 1.0) {
return '100%';
} else {
int value = int.parse(volume.toStringAsPrecision(2).replaceAll('.', ''));
return '$value%';
}
}