percentOf function

int percentOf(
  1. double fraction
)

0..1 fraction → a rounded whole percent (Tor bootstrap progress, where reaching 100 is not a money claim). The bridge guarantees finite percents; clamp alone would pass a NaN through, so guard finiteness explicitly (belt that actually holds).

Implementation

int percentOf(double fraction) {
  final f = fraction.isFinite ? fraction.clamp(0.0, 1.0) : 0.0;
  return (f * 100).round();
}