visaCard static method

bool visaCard(
  1. String cardNumber
)

Validates whether the given cardNumber is a valid Visa card number.

The cardNumber parameter should be a string representing a Visa card number.

Returns true if the cardNumber is valid, false otherwise.

Implementation

static bool visaCard(String cardNumber) {
  String pattern = r'^4[0-9]{12}(?:[0-9]{3})?$';
  RegExp regExp = RegExp(pattern);
  return regExp.hasMatch(cardNumber);
}