formattedPrice function

String formattedPrice(
  1. double? price, [
  2. String? symbol
])

Returns a string representing a formatted price with currency A custom symbol can be provided to be used instead

Implementation

String formattedPrice(double? price, [String? symbol]) {
  if (price == null) return "0";
  return "${symbol ?? "\$"}${price.toStringAsFixed(2)}";
}