Created
September 9, 2024 11:34
-
-
Save BekNaji/dc8de3e5a39972e3d032fa27257703ab to your computer and use it in GitHub Desktop.
Add icon by card number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Builder(builder: (context) { | |
RegExp visaRegExp = RegExp(r'^4[0-9]{3}'); | |
RegExp mastercardRegExp = | |
RegExp(r'^5[1-5][0-9]{2}|^2[2-7][0-9]{2}'); | |
RegExp humoRegExp = RegExp(r'^9[0-9]{3}'); | |
RegExp uzcardRegExp = RegExp(r'^8[0-9]{3}'); | |
if (visaRegExp.hasMatch(params.number!)) { | |
return Image.asset(Assets.visaPng, height: SIZE_16); | |
} else if (mastercardRegExp | |
.hasMatch(params.number!)) { | |
return Image.asset(Assets.mastercardPng, | |
height: SIZE_24); | |
} else if (humoRegExp.hasMatch(params.number!)) { | |
return Image.asset(Assets.humoPng, height: SIZE_24); | |
} else if (uzcardRegExp.hasMatch(params.number!)) { | |
return Image.asset(Assets.uzcardPng, | |
height: SIZE_24); | |
} | |
return const SizedBox(); | |
}), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment