formatDuration static method
Formats seconds/nanos the canonical "3.000001s" way.
Implementation
static String formatDuration(BigInt? seconds, int? nanos) {
final s = seconds ?? BigInt.zero;
final n = nanos ?? 0;
if (n == 0) return '${s}s';
final frac = n
.abs()
.toString()
.padLeft(9, '0')
.replaceAll(RegExp(r'0+$'), '');
final sign = (s.isNegative || n < 0) ? '-' : '';
return '$sign${s.abs()}.$frac'
's';
}