A Dart package that detects credit card types based on their prefixes

Overview

credit_card_type_detector | Credit Card Type Detector

A Dart package that detects credit card types based on the current credit card number patterns

This is a port from Braintree's credit-card-type module

Gif of the example app

Installing

  1. Add dependency to your pubspec.yaml

    Get the current version in the 'Installing' tab on pub.dartlang.org

dependencies:
    credit_card_type_detector: ^1.0.2
  1. Import the package
import 'package:credit_card_type_detector/credit_card_type_detector.dart';

Usage

import 'package:credit_card_type_detector/credit_card_type_detector.dart';

String visa = "4647 7200 6779 1032";

var type = detectCCType(visa);

assert(type == CreditCardType.visa)

Check out the example app in the example directory or the 'Example' tab on pub.dartlang.org for a more complete example using the BLoC pattern

Features

  • No external dependencies
  • Supported cards:
    • Visa
    • Mastercard
    • American Express
    • Discover
    • Diners Club
    • JCB
    • Union Pay
    • Maestro
    • Mir
    • Elo
    • Hiper/Hipercard

Pattern Detection

Each card type has a corresponding list of patterns. See the cardNumPatterns map. Each pattern is an array of strings that represents a range of numbers or a single number. These numbers correspond to the Issuer Identification number (IIN) for the credit card company.

If the pattern is an array with a single number, the package compares it against the card number. Partial matches for card numbers that are shorter than the pattern also match. I.e. given the pattern 123, then the card numbers 1, 12, 123, 1234 will all match, but 2, 13, and 124 will not.

If the pattern is an array of numbers, then the card number is checked to be within the range of those numbers. Again, partial matches are accepted. I.e. given the range [100, 123], then the card numbers 1, 10, 100, 12, 120, 123 will all match, but 2, 13, and 124 will not.

The package loops over every card type and everyone of its corresponding patterns.

API

detectCCType(String number)

Returns: A CreditCardType enum.

I.e. CreditCardType.visa for any card number that starts with '4'.

Related Repos

Author

Cholojuanito (Tanner Davis) - Creator and repo owner - Github Profile

Support

If you think this package is helpful, tell your friends, give it a star on GitHub, and a like on pub.dev

"Buy Me A Pizza"

License

This project is licensed under the MIT License - see the LICENSE file for more details

You might also like...

This is my card using flutter

This is my card using flutter

Mi Card Our Goal Now that you've seen how to create a Flutter app entirely from scratch, we're going to go further and learn more about how to design

Dec 18, 2021

This is simple Ninja ID Card App Code ;)

ninjacard A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if thi

Oct 17, 2022

Flutter - Special animated flip card

Flutter - Special animated flip card

special_card Flutter UI Design | Animated Flip Card. Demo for the app: animated-flip-card.mp4 Getting Started This project is a starting point for a F

Dec 4, 2022

Flutter Card Management App(UI/UX)

Flutter Card Management App(UI/UX)

Flutter Card Managing App - Cardy Bank I uploaded on youtube!! Thanks to Watch Introduction I'm working on a project to launch a simple brand. I tried

Oct 31, 2022

Mi-card-app flutter project

my_card_app A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if t

Dec 2, 2021

A flutter widget where a card is expanded ontap.

A flutter widget where a card is expanded ontap.

Expansion card This package provides an easy implementation of a Expansion type card where you can also add gif at the background. How to use import '

Dec 6, 2022

Find out under which card the Flutter logo is hiding.

Flutter Card Flip Game Find out under which card the Flutter logo is hiding. Game Rules The purpose of this game is for the player to find out under w

Dec 30, 2021

Kraken - a high-performance, web standards-compliant rendering engine based on Flutter.

 Kraken - a high-performance, web standards-compliant rendering engine based on Flutter.

Kraken - a high-performance, web standards-compliant rendering engine based on Flutter.

Jan 7, 2023

Code generation for Flutter Padding widgets based on your constants

Paddinger Paddinger is a Flutter package to generate Padding widgets. Given a set of constants like: @paddinger const double PADDING_NORMAL = 8; A set

Oct 20, 2022
Comments
  • Sample missing in readme

    Sample missing in readme

    Hi

    I think there is something missing in the Usage section of your readme. There is only an import line, and it's missing and example of current usage.

    I'm on my phone now, but maybe I can do a PR later on.

    Thanks for the library!

    opened by sergiandreplace 2
Releases(v2.0.0)
Owner
Tanner Davis
Deep Learning. The hype is real.
Tanner Davis
Flutter Credit Card Input form

This package provides visually beautiful UX through animation of credit card information input form. Preview Installing Add dependency to pubspec.yaml

Jeongtae Kim 426 Jan 5, 2023
Credit Card UI For Flutter

TP1 FLUTTER CREDIT CARD UI FIRST step : must enter the number of credit card then the expired date SECONDE step : you enter the CVV in the back of the

null 0 Nov 8, 2021
Flutter-business-card-app - Flutter + Dart business card mobile app

Dart + Flutter Business Card Mobile Application

Mark Hellner 1 Nov 8, 2022
ID-Card - A Simple ID Card Project Using Flutter

ID-CARD A new Flutter project.A simple demonstration of my time in the Dart lang

edwromero 0 Jan 26, 2022
A flutter package for building card based forms.

Card Settings NOTE: THIS IS EFFECTIVELY NULLSAFE BUT CANNOT REFLECT THIS UNTIL cupertino_settings IS UPGRADED. A flutter package for building settings

CodeGrue 445 Dec 26, 2022
Flutter package - Animated Flip Card

Animated Flip Card Animated Flip Card package lets you add an animated flip card to your Flutter app that hide and show more informations. Features Th

Ulfhrafn 8 Dec 4, 2022
A flutter port of Cardidy, a package to validate or identify card numbers & cvv with ease.

Flutter Cardidy A plugin to validate or identify card numbers & cvv with ease. This flutter package will help you validate card numbers or CVVs and id

Heyramb Narayan Goyal 1 Nov 28, 2021
A simple package that provides you with some widgets and cutom clippers which implements the shape of a coupon card.

Coupon UI Kit A simple package that provides you with some widgets and cutom clippers which implements the shape of a coupon card. The example contain

AbdulMuaz Aqeel 15 Dec 20, 2022
Scratch card widget which temporarily hides content from user.

scratcher Scratch card widget which temporarily hides content from user. Features Android and iOS support Cover content with full color or custom imag

Kamil Rykowski 405 Dec 27, 2022
Flutterwave landing page animated card deck implemented with Flutter

The Flutterwave animated card deck in Flutterwave's landing page implemented with Flutter.

null 38 Nov 10, 2022