formatWireNumber function Protocol
Formats value for the wire: the shortest text that parses back to the
same double, never locale dependent.
Implementation
String formatWireNumber(double value) {
if (value.isNaN) return 'nan';
if (value.isInfinite) return value > 0 ? 'inf' : '-inf';
if (value == value.truncateToDouble() && value.abs() < 1e15) {
return value.toInt().toString();
}
return value.toString();
}