formatScale method

String formatScale(
  1. double scale
)

Implementation

String formatScale(double scale) {
  if (scale % 1 == 0) {
    return '${scale.toStringAsFixed(1)}x'; // 1.0 -> "1.0x", 2.0 -> "2.0x"
  } else if (scale * 100 % 10 == 0) {
    return '${scale.toStringAsFixed(1)}x'; // 1.5 -> "1.5x", 1.7 -> "1.7x"
  } else {
    return '${scale.toStringAsFixed(2)}x'; // 3.75 -> "3.75x"
  }
}