Flutter Fix
No Result
View All Result
  • Login
  • Register
  • Media
    • Music
    • Video
    • Images
    • Gallery
  • Flutter Apps
    • Finance App
    • Weather App
    • Video App
    • Music App
    • Shopping App
    • World Clock
    • ECommerce
    • Mobile Web Browser
  • Menu
    • Buttons
    • App Bar
    • Floating Action Button
    • Toast
    • Tab Bar
    • Swipe
  • Components
    • Developers Point
    • Animations
    • Loading
    • Flutter Packages
    • WebView
  • Inputs
    • Forms
    • TextField
    • Toggle Button
    • Download
    • Widgets
  • Games
  • UI
    • Material Design
    • Card
    • Flutter Widgets
    • Neomorphism
    • Navigation
  • Navigation
  • Q&A
  • Dart
    • Flutter Methods
FORUM
ASK QUESTION
  • Media
    • Music
    • Video
    • Images
    • Gallery
  • Flutter Apps
    • Finance App
    • Weather App
    • Video App
    • Music App
    • Shopping App
    • World Clock
    • ECommerce
    • Mobile Web Browser
  • Menu
    • Buttons
    • App Bar
    • Floating Action Button
    • Toast
    • Tab Bar
    • Swipe
  • Components
    • Developers Point
    • Animations
    • Loading
    • Flutter Packages
    • WebView
  • Inputs
    • Forms
    • TextField
    • Toggle Button
    • Download
    • Widgets
  • Games
  • UI
    • Material Design
    • Card
    • Flutter Widgets
    • Neomorphism
    • Navigation
  • Navigation
  • Q&A
  • Dart
    • Flutter Methods
No Result
View All Result
Flutter Fix
No Result
View All Result
Home UI Card

A Flutter package that detects credit card types from the first input

September 7, 2020
in Card, Finance App, Flutter Apps
3 min read
A Flutter package that detects credit card types from the first input

Here’s a flutter dart plugin that would detect the credit cart type that is being inputed based on the prefix.

RELATED FLUTTER RESOURCES

A Full News Blog App made with Flutter + Source Code

A Simple Hacker News reader app built in Flutter

A Weather App made with Flutter using OpenWeather API + Source Code

Credit Card Type Detector || credit_card_type_detector

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

ADVERTISEMENT

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

Installing

  1. Add dependency to your pubspec.yamlGet 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’.

Screenshot

GitHub

A Dart package that detects credit card types based on their prefixes
https://github.com/cholojuanito/credit_card_type_detector
6 forks.
19 stars.
0 open issues.
Recent commits:

  • Merge pull request #2 from cholojuanito/devVersion 2.0.0 pre release for Dart null safety, GitHub
  • Version 2.0.0 for null safety prep, Tanner Davis
  • More unit tests and edge cases. Handles non-numeric chars, Tanner Davis
  • Updated to version 1.1.0, Tanner Davis
  • More stuff because the gif wasn't working, Tanner Davis

RelatedFlutter Resource

Flutter Apps

A Full News Blog App made with Flutter + Source Code

September 15, 2020
A Simple Hacker News reader app built in Flutter
Flutter Apps

A Simple Hacker News reader app built in Flutter

September 15, 2020
A Weather App made with Flutter using OpenWeather API + Source Code
Flutter Apps

A Weather App made with Flutter using OpenWeather API + Source Code

September 7, 2020
A BMI Calculator app developed with Flutter + Source Code
Flutter Apps

A BMI Calculator app developed with Flutter + Source Code

September 7, 2020
A Simple App to Manage Passwords – made with Flutter + Source Code
Flutter Apps

A Simple App to Manage Passwords – made with Flutter + Source Code

September 2, 2020
Corona Virus Tracker App Built with Flutter
Flutter Apps

Corona Virus Tracker App Built with Flutter

September 1, 2020
Next Post
A Simple Hacker News reader app built in Flutter

A Simple Hacker News reader app built in Flutter

A Beautiful Bottom navigation bar with bubble click effect in Flutter

A Beautiful Bottom navigation bar with bubble click effect in Flutter

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recommended Stories

flutter future async await

Flutter Future, Await, and Async – All You Need To Know

July 21, 2020
A Flutter package to get Instagram user details and download reels videos

A Flutter package to get Instagram user details and download reels videos

August 8, 2020

Flutter Beautiful Sidebar/Navigation Bar that Collapses when clicked

September 15, 2020

Popular Stories

  • FLUTTER-FUTUER-APP-DEVELOPMENT

    Why Google Flutter Is the Future of Mobile App Development

    0 shares
    Share 0 Tweet 0
  • Container Widget & Box Model in Flutter – All You Need To Know

    0 shares
    Share 0 Tweet 0
  • Flutter Future, Await, and Async – All You Need To Know

    0 shares
    Share 0 Tweet 0
  • Create a Beautiful & Customized Tab/Toggle in Flutter

    0 shares
    Share 0 Tweet 0
  • Flutter Form & FormField Widget – Implementation & Example

    0 shares
    Share 0 Tweet 0
  • HOME
  • ABOUT US
  • CONTACT US
  • DMCA
  • TERMS & CONDITIONS
  • PRIVACY POLICY
Call us: +234 705 505 5426

© 2020 FlutterFix - Best Flutter Tool, Library, Source Code, Forum and Tutorials FlutterFix.

No Result
View All Result
  • Media
    • Music
    • Video
    • Images
    • Gallery
  • Flutter Apps
    • Finance App
    • Weather App
    • Video App
    • Music App
    • Shopping App
    • World Clock
    • ECommerce
    • Mobile Web Browser
  • Menu
    • Buttons
    • App Bar
    • Floating Action Button
    • Toast
    • Tab Bar
    • Swipe
  • Components
    • Developers Point
    • Animations
    • Loading
    • Flutter Packages
    • WebView
  • Inputs
    • Forms
    • TextField
    • Toggle Button
    • Download
    • Widgets
  • Games
  • UI
    • Material Design
    • Card
    • Flutter Widgets
    • Neomorphism
    • Navigation
  • Navigation
  • Q&A
  • Dart
    • Flutter Methods

© 2020 FlutterFix - Best Flutter Tool, Library, Source Code, Forum and Tutorials FlutterFix.

Welcome Back!

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In