import 'package:intl/intl.dart'; /// Utility class for formatting values class Formatters { Formatters._(); /// Format price with currency symbol static String formatPrice(double price, {String currency = 'USD'}) { final formatter = NumberFormat.currency(symbol: '\$', decimalDigits: 2); return formatter.format(price); } /// Format date static String formatDate(DateTime date) { return DateFormat('MMM dd, yyyy').format(date); } /// Format date and time static String formatDateTime(DateTime dateTime) { return DateFormat('MMM dd, yyyy hh:mm a').format(dateTime); } /// Format time only static String formatTime(DateTime time) { return DateFormat('hh:mm a').format(time); } /// Format number with thousand separators static String formatNumber(int number) { final formatter = NumberFormat('#,###'); return formatter.format(number); } /// Format percentage static String formatPercentage(double value, {int decimals = 0}) { return '${value.toStringAsFixed(decimals)}%'; } /// Format quantity (e.g., "5 items") static String formatQuantity(int quantity) { return '$quantity ${quantity == 1 ? 'item' : 'items'}'; } }