formatCost function
Format cost as a string.
Implementation
String formatCost(double cost) {
if (cost < 0.01) return '\$${cost.toStringAsFixed(4)}';
if (cost < 1.0) return '\$${cost.toStringAsFixed(3)}';
return '\$${cost.toStringAsFixed(2)}';
}