formatPercent function Null safety

String formatPercent(
  1. int value,
  2. int total,
  3. {bool withSign = false}
)

Implementation

String formatPercent(int value, int total, {bool withSign = false}) {
  final p = value / total * 100.0;
  final sign = (withSign && value > 0) ? '+' : '';
  return '${sign}${p.toStringAsFixed(2)}%';
}