formatPKR function

String formatPKR(
  1. num amount
)

Formats an amount as Pakistani Rupees with comma separators, rounded to whole rupees: "Rs. 150,000". Negative amounts are prefixed with - ("-Rs. 500").

Throws an ArgumentError (a RangeError in the npm package) if amount is NaN or infinite.

Implementation

String formatPKR(num amount) {
  _assertFinite(amount);
  final value = amount.toDouble();
  final rounded = jsRound(value.abs());
  final sign = value < 0 && rounded != 0 ? '-' : '';
  return '${sign}Rs. ${_group(rounded)}';
}