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
Business Card - Business Card App Built With Flutter

Business Card app. Basic single page app with functionality. For now you can cha

buraktaha 5 Apr 20, 2022
This is a UI created in FLUTTER. credit ~mitch koko youtuber

project_smarthomeui A new Flutter project. Getting Started This is the image of above code[UI] A few resources to get you started if this is your firs

Vipul Kumawat 3 Nov 17, 2022
A new Flutter project. Use of Padding Class(Widget) and Card Class (Widget)

Use_Of_Card_And_Padding_Class A new Flutter project. Use of Padding Class(Widget) and Card Class (Widget) Getting Started This project is a starting p

Avinandan Bose 1 Mar 18, 2022
A Flutter project to show a personal business card. 📱ℹ️

Mi Card Mi Card Flutter (Practice Project) ?? ℹ ?? What is Mi Card Mi Card is a personal business card. Imagine every time you wanted to give someone

Masiha Jafari 0 Jan 4, 2022
Card-slider-flutter - Implementation of swipeable image cards with dot indicators

card_slider A new Flutter project. Getting Started This project is a starting po

Ryan Egbejule-jalla 1 Sep 17, 2022
Card Swipe Animation Ruchika GuptaCard Swipe Animation [404⭐] - Swipe cards template by Ruchika Gupta.

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
Travel Folding Card with hover animation

travelfoldingcard Travel Folding Card with hover animation The live version is in my Flutter CodePen The original CodePen is from Madalena, which is c

Mahtab Tadayon 4 Jun 9, 2022
Shopping card UI

Shopping Card This Ui focuss on: sreen adaptability Modular code Animation Note 1: This a project that was focussing on a new way of organising my cod

null 43 Oct 5, 2022
Cowin smart print - A GUI based CoWIN Certificate to Smart Card Converter

CoWIN Smart Print A GUI based CoWIN Certificate to Smart Card Converter. Feature

Shreyam Maity 2 Mar 9, 2022
Contribute in building the Ultimate GitBook of Developers by creating your git-card.json

Contribute in building the Ultimate GitBook of Developers by creating your git-card.json gitcards The Attractive and Interactive Variant of your GitHu

omega ui 1 Apr 8, 2022
This Country Selector UI Library written by Dart and Fluter and supports three locales with country's name, achieves lazy loading, and country card animation on listview

Country Selector Widget This Country Selector Widget UI Library written by Dart and Fluter and supports three locales with country's name, achieves la

Klaus 6 Nov 15, 2022
Widget to count the amount of nested widget tree, useful in the dynamic construction of the interface when it is important to know the depth of widget.

widget_tree_depth_counter Widget Tree Depth Counter WidgetTreeDepthCounter is a simple widget to count the amount of nested widget tree, useful in the

Riccardo Cucia 4 Aug 1, 2022
MindInventory 15 Sep 5, 2022
A simple detailed flutter widget that looks almost the same as the real instagram mention widget.

Instagram Mention Widgets 'small details do matter' ❤️ This package provides simple and almost the same UI details that the real Instagram mention wid

AbdulMuaz Aqeel 20 Oct 10, 2022
A customizable carousel slider widget in Flutter which supports inifinte scrolling, auto scrolling, custom child widget, custom animations and built-in indicators.

flutter_carousel_widget A customizable carousel slider widget in Flutter. Features Infinite Scroll Custom Child Widget Auto Play Horizontal and Vertic

NIKHIL RAJPUT 7 Nov 26, 2022
A flutter widget which renders its child outside the original widget hierarchy.

overlay_container A flutter widget which renders its child outside the original widget hierarchy. Demo. This demo is present as an example here. You c

Mustansir Zia 30 Jun 10, 2022
Behruz Hurramov 0 Dec 29, 2021
FT-Custom-Widget - A Custom Widget Built With Flutter

Custom Widget Watch it on YouTube Product Screen Sample when you implement compl

Firgia 5 Mar 29, 2022