unformatMoney function

double unformatMoney(
  1. String input
)

Implementation

double unformatMoney(String input) {
  try {
    // Remove currency symbol (e.g. NGN, $, €) and commas
    String unformatted = input.replaceAll(RegExp(r'[^\d.]'), '');

    // Attempt to parse the value into a double
    double value = double.parse(unformatted);
    return value;
  } catch (e) {
    // If there is an error (e.g., invalid input), return 0.0 or handle it as needed
    print("Error parsing input: $e");
    return 0.0; // You could also throw an exception or return another value
  }
}