A credit card widget for Flutter application.

Overview

alt text

Flutter Credit Card

A Flutter package allows you to easily implement the Credit card's UI easily with the Card detection.

Codacy Badge

Preview

The example app running in Android

Installing

  1. Add dependency to pubspec.yaml

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

dependencies:
    flutter_credit_card: <latest_version>
  1. Import the package
import 'package:flutter_credit_card/flutter_credit_card.dart';
  1. Adding CreditCardWidget

With required parameters

    CreditCardWidget(
        cardNumber: cardNumber,
        expiryDate: expiryDate, 
        cardHolderName: cardHolderName,
        cvvCode: cvvCode,
        showBackView: isCvvFocused, //true when you want to show cvv(back) view
    ),

With optional parameters

    CreditCardWidget(
        cardNumber: cardNumber,
        expiryDate: expiryDate,
        cardHolderName: cardHolderName,
        cvvCode: cvvCode,
        showBackView: isCvvFocused,
        cardbgColor: Colors.black,
        glassmorphismConfig: Glassmorphism.defaultConfig(),
        backgroundImage: 'assets/card_bg.png',
        obscureCardNumber: true,
        obscureCardCvv: true,
        isHolderNameVisible: false,
        height: 175,
        textStyle: TextStyle(color: Colors.yellowAccent),
        width: MediaQuery.of(context).size.width,
        isChipVisible: true,
        isSwipeGestureEnabled: true,
        animationDuration: Duration(milliseconds: 1000),
        customCardIcons: <CustomCardTypeImage>[
                    CustomCardTypeImage(
                      cardType: CardType.mastercard,
                      cardImage: Image.asset(
                        'assets/mastercard.png',
                        height: 48,
                        width: 48,
                      ),
                    ),
                  ],
    ),

Glassmorphism UI

  • Default configuration
    CreditCardWidget(
        glassmorphismConfig: Glassmorphism.defaultConfig(),
    ),
  • Custom configuration
    CreditCardWidget(
        glassmorphismConfig: Glassmorphism(
          blurX: 10.0,
          blurY: 10.0,
          gradient: LinearGradient(
            begin: Alignment.topLeft,
            end: Alignment.bottomRight,
            colors: <Color>[
              Colors.grey.withAlpha(20),
              Colors.white.withAlpha(20),
            ],
            stops: const <double>[
              0.3,
              0,
            ],
          ),
        ),
    ),
  1. Adding CreditCardForm
    CreditCardForm(
      formKey: formKey, // Required 
      onCreditCardModelChange: (CreditCardModel data) {}, // Required
      themeColor: Colors.red,
      obscureCvv: true, 
      obscureNumber: true,
      isHolderNameVisible: false,
      isCardNumberVisible: false,
      isExpiryDateVisible: false,
      cardNumberDecoration: const InputDecoration(
        border: OutlineInputBorder(),
        labelText: 'Number',
        hintText: 'XXXX XXXX XXXX XXXX',
      ),
      expiryDateDecoration: const InputDecoration(
        border: OutlineInputBorder(),
        labelText: 'Expired Date',
        hintText: 'XX/XX',
      ),
      cvvCodeDecoration: const InputDecoration(
        border: OutlineInputBorder(),
        labelText: 'CVV',
        hintText: 'XXX',
      ),
      cardHolderDecoration: const InputDecoration(
        border: OutlineInputBorder(),
        labelText: 'Card Holder',
      ),
    ),

How to use

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

Credit

This package's animation is inspired from from this Dribbble art.


Main Contributors


Vatsal Tanna

Devarsh Ranpara

Kashifa Laliwala

Sanket Kachchela

Meet Janani

Note

We have updated license of flutter_credit_card from BSD 2-Clause "Simplified" to MIT.

License

MIT License

Copyright (c) 2021 Simform Solutions

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


Comments
  • 'Done' button not working on Card Holder Name Textfield

    'Done' button not working on Card Holder Name Textfield

    In CreditCardForm Widget, When the user enters cardholder Name and wants to close the keyboard after that. The user clicks on the Done button but that doesn’t work properly.

    Expected behavior: When User Click on done Keyboard close.

    Demo Video:

    https://user-images.githubusercontent.com/68920259/132684177-67752f0b-5543-41a0-a27d-aced572f2969.mp4

    The device I use for testing

    • iphone11
    • ioS 14.5
    bug 
    opened by waqas-ahmad762 6
  • New credit card brands (Elo/Hipercard) and icons was added.

    New credit card brands (Elo/Hipercard) and icons was added.

    Hi everyone.

    Thanks for the library. It's awesome!

    We miss the Elo and Hipercard card brands, so I created this pull request to add them.

    This pr add Elo and Hipercard brands to the Credit Card Widget.

    opened by tceccatto 5
  • Initialize values

    Initialize values

    Could you add values at startup to help with editing?

    void initState() {
    super.initState();
    
    createCreditCardModel();
    
    onCreditCardModelChange = widget.onCreditCardModelChange;
    
    cvvFocusNode.addListener(textFieldFocusDidChange);
    
    _cardNumberController.text = cardNumber;
    _expiryDateController.text = expiryDate;
    _cardHolderNameController.text = cardHolderName;
    
    enhancement 
    opened by MarceloRab 5
  • feat: Added formfield keys for manual field validation checks

    feat: Added formfield keys for manual field validation checks

    Sample use-cases:

    • Upon entering card number, show check indicating field valid
    • Validate form fields manually & enable 'save' or 'update' card buttons.

    Upon entering all required information, calling formKey.currentState.validate() on each onCreditCardModelChange changed validates every field showing all error message, bad UX.

    Allowing separate form field keys gives control to developer validating separate fields as required.

    opened by cybex-dev 4
  • Using Glassmorphism on iOS force close the app

    Using Glassmorphism on iOS force close the app

    Clicking on Glassmorphism force close the app on iOS.

    To Reproduce Steps to reproduce the behavior:

    1. Run 'example.dart'
    2. Click on 'Glassmorphism'

    Video

    https://user-images.githubusercontent.com/64292174/152927412-0d878c32-3ae0-410e-b35d-750f08d0d848.mov

    • iOS simulator
    • iOS version - 15.2
    • Flutter version - 2.10.0
    opened by UsamaKarim 4
  • The cards expired date validation control bug fixed.

    The cards expired date validation control bug fixed.

    The expiry date on the cards should be based on the last day of that month. Since the current structure is based only on the month, it does validation not work correctly. As a bug fix, the last day of the month was found and added to the card expiry date.

    opened by ocakliemre 4
  • Optional function to execute on done form

    Optional function to execute on done form

    At the end of filling in the card data I send them to the backend of my project, I have a button that makes this submit, in my use case it is interesting for the submit to happen at the end of the form, I believe that for other people too.

    opened by mateusdalmeida 4
  • Is it Secure to store credit card data?

    Is it Secure to store credit card data?

    Hello, I am thinking to use this widget but I am not sure it is ok to store credit card in the app. Is the data encrypted ? What should I do to make this data secure in my app?

    opened by macmatrix 4
  • Flutter web issue

    Flutter web issue

    transform.setEntry(3, 2, 0.001); transform.rotateY(animation.value);

    This transformation is giving following issue in latest flutter web: PersistedOffset: is in an unexpected state. Expected one of: PersistedSurfaceState.active, PersistedSurfaceState.released But was: PersistedSurfaceState.pendingRetention

    opened by bibash28 3
  • Security code can be named also as

    Security code can be named also as "CVC", not only "CVV"

    Describe the bug I tought that it was a typo, but the security code can be named in both ways. If you want just close the issue, or if it has any different meaning, consider to let the dev. choose between the two options maybe?

    Screenshots immagine

    enhancement 
    opened by funder7 3
  • Add

    Add "isValid" property to CreditCardForm

    Is your feature request related to a problem? Please describe. Nope

    Describe the solution you'd like I'd like to have a property, or a callback, to know if the inserted credit card data is valid or not (a sort of validation result)

    Describe alternatives you've considered A ValueChanged<bool> isValid linked to the form validation would be enough

    enhancement 
    opened by funder7 3
  • change in cardBgColor doesn't work when widget is rebuilt

    change in cardBgColor doesn't work when widget is rebuilt

    Describe the bug I am using flutter_credi_card version version 3.0.4. The problem is that when my widget containing CreditCardWidget() is rebuilt, the cardBgColor doens't change accordingly. I tried using the glassmorphismConfig and changing the gradient colors and it works just fine.

    To Reproduce This is my code if someone want to reproduce the issue:

    const List<String> cardColors = ['ffffcba4', 'ffcdd5ea', 'ffbae1ff', 'ffffb3ba', 'ff5a5a5a'];
    
    /// State
    class CardsState extends Equatable {
      const CardsState({
        this.color = 'bae1ff',
      });
    
      final String color;
    
      @override
      List<Object> get props => [color];
    
      CardsState copyWith({
        String? color,
      }) {
        return CardsState(
          color: color ?? this.color,
        );
      }
    }
    
    /// Event
    class ColorChange extends CardsEvent {
      const ColorChange(this.color);
    
      final String color;
    
      @override
      List<Object> get props => [color];
    }
    
    /// Bloc
    class CardsBloc extends Bloc<CardsEvent, CardsState> {
      CardsBloc() : super(const CardsState()) {
        on<ColorChange>(_onColorChange);
      }
    
      void _onColorChange(ColorChange event, Emitter<CardsState> emit) {
        emit(state.copyWith(color: event.color));
      }
    }
    
    /// Screen
    class NewCard extends StatefulWidget {
      const NewCard({super.key});
    
      @override
      State<NewCard> createState() => _NewCardState();
    }
    
    class _NewCardState extends State<NewCard> {
      @override
      Widget build(BuildContext context) {
        return BlocConsumer<CardsBloc, CardsState>(
          listener: (context, state) {
            // Some listeners
          },
          buildWhen: (previous, current) => previous != current,
          builder: (context, state) {
            return Scaffold(
              appBar: AppBar(
                title: const Text('New card'),
                centerTitle: false,
              ),
              body: SafeArea(
                child: Padding(
                  padding: const EdgeInsets.all(10),
                  child: ListView(
                    children: [
                      const _CreditCard(),
                      const _Colors(),
                    ],
                  ),
                ),
              ),
            );
          },
        );
      }
    }
    
    /// Credit card widget
    class _CreditCard extends StatelessWidget {
      const _CreditCard();
    
      @override
      Widget build(BuildContext context) {
        final state = context.watch<CardsBloc>().state;
        return CreditCardWidget(
          isHolderNameVisible: true,
          cardNumber: '1111222233334444',
          expiryDate: '12/26',
          cardHolderName: 'Foo Bar',
          cvvCode: '123',
          showBackView: false,
          onCreditCardWidgetChange: (p0) {},
          isChipVisible: false,
          cardBgColor: Color(int.parse(state.color, radix: 16)),
        );
      }
    }
    
    /// Color selection widget
    class _Colors extends StatelessWidget {
      const _Colors();
    
      @override
      Widget build(BuildContext context) {
        final state = context.watch<CardsBloc>().state;
        return Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: cardColors
              .map(
                (color) => IconButton(
                  onPressed: () => context.read<CardsBloc>().add(ColorChange(color)),
                  icon: Container(
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(100),
                      border: Border.all(width: 1.5, color: state.color == color ? Colors.white : Colors.transparent),
                    ),
                    child: Icon(
                      Icons.fiber_manual_record,
                      color: Color(int.parse(color, radix: 16)),
                      size: 32,
                    ),
                  ),
                ),
              )
              .toList(),
        );
      }
    }
    
    

    The result i expect: when i click on a IconButton referred to a color the background color of the card should change to the selected one. As I say initially, this behavior is correct when using glassmorphismConfig but not with cardBgColor. On top of that, if i make an hardcoded change to the cardBgColor property (eg: from Colors.red to Colors.green) I have to restart my application because the only hot reload doesn't trigger the change.

    Tested on iPhone 13 emulator.

    I hope this info I gave you would help resolve this problem. If I miss something or someone need more informations please let me know

    opened by carloberd 1
  • Package Not Sync To PUB.DEV

    Package Not Sync To PUB.DEV

    Hi, the package wasn't actualized on pub.dev because for example the CreditCardBrand ins't detecting th HIPERCARD brand with the number initial 606282.

    I downloaded the package version 3.0.4 directly from pub.dev and compared from Github and the file lib/credit_card_widget.dart are differents.

    How to upgrade the package in pub.dev?

    ![image](https://user-images.githubusercontent.com/7996929/203844035-c5d9cc2c-ef4e-45dc-abb6-2ce6386c3784.png)

    credit_card_widget.dart

    Version 3.0.4 (GITHUB) final code: enum CardType { otherBrand, mastercard, visa, americanExpress, discover, elo, hipercard }

    Version 3.0.4 (PUB.DEV) final code (falting elo and hipercard!): enum CardType { otherBrand, mastercard, visa, americanExpress, discover, }

    opened by fhariano 1
  • News Credit Card Num Pattern

    News Credit Card Num Pattern

    Hey, guys!

    I detected that in the card number pattern list, there is still a need to adjust:

    • The Hipercard pattern are only the initial numbers 38 and 60;
    • ELO just add these patterns: 4011, 4576 and 5067.

    Thanks!

    opened by fhariano 0
  • Can you make CVC part optional in CreditCardForm Widget?

    Can you make CVC part optional in CreditCardForm Widget?

    Hey. Thanks for the package. Can you make CVC part of CreditCardForm widget optional? I would like to add credit card info locally. Thus CVC is not needed in our app.

    enhancement 
    opened by Ruslanbek0809 0
  • Web build displaying

    Web build displaying "Not Safe" alert to users

    Describe the bug In web server, the form is displaying a "Not Safe" alert to users and disabling autofill behaviour of the form. Chrome / Android also shows up the built in Credit Card scanner to make a photo of a new credit card but it didn't fill the fields at the form.

    To Reproduce Just deploy the master example, deploy it over a web server and test to autocomplete the form using Chrome or Safari browsers.

    Expected behavior I expected Chrome and Safari to autofill previously saved credit card numbers of the users. Also expected Chrome to fill the form based on Credit Card scanner of a new card.

    Screenshots Not safe - autofill disabled

    Additional context I have created a simple form with only autocomplete enabled form and the feature works perfectly: https://payment.gula.mobi/card.html

    But the form generated by the widget doesn't work: https://payment.gula.mobi/

    bug 
    opened by esmlima 0
Releases(3.0.4)
Owner
Simform Solutions
Simform Solutions
A simple easy to use Flutter DApp , which keeps a track of all your day to day transactions by using Ethereum blockchain in the background which in turn increases your credit score.

Sahayog A simple easy to use Flutter DApp , which keeps a track of all your day to day transactions by using Ethereum blockchain in the background whi

Utkarsh Agarwal 15 May 21, 2022
FlutterCardSwipe Card Swipe Animation Creating the swipe view as used in the Tinder.

FlutterCardSwipe Card Swipe Animation Creating the swipe view as used in the Tinder. Swipe right is considered accepted and swipe left is rejected.It

Ruchika Gupta 517 Dec 27, 2022
null 357 Dec 27, 2022
We'll have a shop like this where we can add items to a cart in that card.

shop We'll have a shop like this where we can add items to a cart in that card. We can also delete such items. We'll have different pages. We can navi

Avinash Poshiya 1 Dec 7, 2021
This is application using Flutter for develop a trello application

flutter_desktop_trello A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you s

Dao Hong Vinh 14 Aug 16, 2022
GChat is a chatting application developed using Flutter(Dart) and firebase for 2 users. Trying to Develop an application that does not sell your data with whatsapp rolling out its privacy policy updates.

Gchat - The Chatting Application A Flutter project for chatting. I used Android Studio and you can you any editor of your choice for ex: VS Code, Inte

Sanchaksh Kaul 6 Nov 6, 2022
Chat-application - Build Chat Application using Flutter and Firebase

Build Chat Application using Flutter & Firebase Source Code - Enjoy ! Social Med

Muhammad Irvan 0 Jan 3, 2022
The application helps the patient to follow up on medication schedules, and each patient has his own profile. The application is connected to Bluetooth to help the patient's dependents follow up on the patient.

spoon_medicines A new Flutter application. Getting Started This project is a starting point for a Flutter application. A few resources to get you star

null 0 Nov 27, 2021
Weather-application - A weather application based on dart programming language

weather based mobile app A new Flutter project with dart programmingg language S

Munem Sarker 5 Nov 13, 2022
Learn Flutter on Flutter! A widget directory with implementation samples!

Fludget Browse through a variety of widgets used in flutter This application is developed to learn Flutter using Flutter. Different widgets used in fl

ACM VIT 29 Nov 23, 2022
QR.Flutter is a Flutter library for simple and fast QR code rendering via a Widget or custom painter.

QR.Flutter is a Flutter library for simple and fast QR code rendering via a Widget or custom painter. Need help? Please do not submit an issue for a "

Yakka 612 Jan 4, 2023
FileManager is a wonderful widget that allows you to manage files and folders, pick files and folders, and do a lot more. Designed to feel like part of the Flutter framework.

File Manager FileManager is a wonderful widget that allows you to manage files and folders, pick files and folders, and do a lot more. Designed to fee

Devs On Flutter 52 Dec 30, 2022
A Flutter widget to create an iOS settings-table (static TableView).

flutter_cupertino_settings A Flutter widget to create an iOS settings-table (static TableView). import 'package:flutter_cupertino_settings/flutter_cup

Matthias Rupp 234 Dec 28, 2022
Flutter - Blur Widgets - BackdropFilter Widget

blur_widgets Flutter - Blur Widgets - BackdropFilter Widget. Screenshot: Getting Started This project is a starting point for a Flutter application. A

Ulfhrafn 3 Dec 4, 2022
Flutter Widget to display PDF

pdf_flutter Inspired by Pdf_Viewer_Plugin ?? Wrapped around AndroidPdfViewer on Android. ???? 1. Add pdf_flutteron pubspec.yml dependencies: pdf_flu

Laxman Bhattarai 100 Sep 7, 2022
A simple flutter widget to paint with your fingers

painter A simple flutter widget to paint with your fingers. Features The widget supports: Changing fore- and background color Changing the thickness o

EPNW 133 Dec 26, 2022
A Flutter widget that help you to create badages

badge A Flutter widget that help you to create badges easily. Getting Started Add dependency to pubspec.yaml [...] dependencies: badge: any [...] In

Raouf Rahiche 85 Jul 14, 2022
A flutter widget that show the camera stream and allow ML vision recognition on it, it allow you to detect barcodes, labels, text, faces...

Flutter Camera Ml Vision A Flutter package for iOS and Android to show a preview of the camera and detect things with Firebase ML Vision. Installation

Rushio Consulting 257 Jan 2, 2023
This is a basic flutter widget that shows the Buy me a coffee button.

Buy me a coffee widget Did you ever needed a widget for buy me a coffee, well here it is. Important note Be very careful with using this widget. Accor

Max Weber 8 May 12, 2022