getBrandByCreditCardNumber method

String? getBrandByCreditCardNumber(
  1. String creditCardNumber
)

Implementation

String? getBrandByCreditCardNumber(String creditCardNumber) {
  creditCardNumber = creditCardNumber.replaceAll(RegExp(r"[^\d]"), "");

  for (var brand in _brands) {
    if (RegExp(brand.brand).hasMatch(creditCardNumber)) return brand.name;
  }

  return null;
}