fromString static method

PaystackCurrency? fromString(
  1. String code
)

Returns a PaystackCurrency from its ISO 4217 code (case-insensitive), or null if no match is found.

Example:

PaystackCurrency.fromString('GHS') // => PaystackCurrency.ghs
PaystackCurrency.fromString('ghs') // => PaystackCurrency.ghs
PaystackCurrency.fromString('XYZ') // => null

Implementation

static PaystackCurrency? fromString(String code) {
  final upper = code.toUpperCase();
  for (final c in PaystackCurrency.values) {
    if (c.value == upper) return c;
  }
  return null;
}