Skip to content

An unofficial Flutter port of Cardidy, a package to validate or identify card numbers & cvv with ease.

License

Notifications You must be signed in to change notification settings

hey24sheep/flutter_cardidy

Repository files navigation

Flutter Cardidy

pub package publisher pub package GitHub Stars Flutter Tests

Buy Me A Coffee

A plugin to validate or identify card numbers & cvv with ease.

This flutter package will help you validate card numbers or CVVs and identiy card issuing provider with minimal code and efforts.

  • simple and easy
  • regex-free
  • up-to-date with Wikipedia
  • no other dependencies
  • well documented
  • production-ready

This package is a Flutter port of original package Cardidy written in C#.


NOTE: The closer we are to an official spec is the Wikipedia's Payment card number page.

Installation

      dependencies:
        flutter_cardidy: ^1.0.0

Getting Started

Add the dependency to your project and start using Flutter Cardidy everywhere:

Import the package.

import 'package:flutter_cardidy/flutter_cardidy.dart';

To validate and identify card's issuing provider

// single card number identification
final result = FlutterCardidy.identify("4127540509730813");
Console.WriteLine(result.first); // print Visa

Multi card identification

// returns a KVP Map of, cardnum as key & result as value
final mapResult = FlutterCardidy.identifyMultiple(["4127540509730813","4771320594031"]);

Validating CVV

var cvv = "123";
var visaCvvIsValid = FlutterCardidy.isCvvValid(cvv, CardType.Visa);

Validating card number without identification

var isCardValid = FlutterCardidy.isCardNumberValid("47!Z320594033");

Properties

Return type of Identify is List<CardType>. A card is sometimes a co-branded card like Visa or Visa Electron, in this case all matching providers are returned.

Property Type Default Note
cardNumString (required) String - Your card number input string
validateLength bool true Validate the length as part of the String identification.
A false value can be useful to identify the fragment of a card number.
ignoreNoise bool false Ignore common noise found in card number. This noise is any of - ..
handleAnonymization bool false Set any non-digits to zero. It is common to use "X" and "#" to hide some digits.

Improve

Help me by reporting bugs, submit new ideas for features or anything else that you want to share.

  • Just write an issue on GitHub. ✏️
  • And don't forget to hit the like button for this package ✌️

More

Check out my other useful packages on pub.dev

License

MIT