getCardTypeFrmNumber static method
Implementation
static CardType getCardTypeFrmNumber(String input) {
CardType cardType;
if (input.startsWith( RegExp(
r'((5[1-5])|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720))'))) {
cardType = CardType.Master;
} else if (input.startsWith(RegExp(r'[4]'))) {
cardType = CardType.Visa;
} else if (input
.startsWith(RegExp(r'((506(0|1))|(507(8|9))|(6500))'))) {
cardType = CardType.Verve;
} else if (input.startsWith(RegExp(r'((34)|(37))'))) {
cardType = CardType.AmericanExpress;
} else if (input.startsWith(RegExp(r'((6[45])|(6011))'))) {
cardType = CardType.Discover;
} else if (input
.startsWith(RegExp(r'((30[0-5])|(3[89])|(36)|(3095))'))) {
cardType = CardType.DinersClub;
} else if (input.startsWith(RegExp(r'(352[89]|35[3-8][0-9])'))) {
cardType = CardType.Jcb;
} else if (input.length <= 8) {
cardType = CardType.Others;
} else {
cardType = CardType.Invalid;
}
return cardType;
}