formatShare function
Formats part as a percentage of total, for example 0.4%.
Implementation
String formatShare(final double part, final double total) {
if (total <= 0 || part <= 0) {
return '0%';
}
final double percent = part / total * 100;
return '${percent.toStringAsFixed(percent >= 10 ? 0 : 1)}%';
}