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),
    ),

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.

License

BSD 2-Clause License

Copyright (c) 2019, Simform Solutions
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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
UI Card Designs - A new Flutter application.

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

Mohit rao 14 Dec 23, 2022
Sliding card is a highly customizable flutter package that will help you create beautiful Cards with a sliding animation effect.

Sliding Card Introduction Sliding card is a highly customizable flutter package that will help you create beautiful Cards with a sliding animation eff

null 21 Nov 4, 2022
A Facebook & Twitter Like Card Loading Shimmer Skeleton Library.

PKSkeleton A Facebook & Twitter Like Card Loading Shimmer Skeleton Library. The source code is 100% Dart, and everything resides in the /lib folder. S

Pawan Kumar 283 Nov 26, 2022
A simple Flutter widget to add in the widget tree when you want to show nothing, with minimal impact on performance.

nil A simple widget to add in the widget tree when you want to show nothing, with minimal impact on performance. Why? Sometimes, according to a condit

Romain Rastel 127 Dec 22, 2022
A flutter carousel widget, support infinite scroll, and custom child widget.

carousel_slider A carousel slider widget. Features Infinite scroll Custom child widgets Auto play Supported platforms Flutter Android Flutter iOS Flut

Bart T 1 Nov 25, 2021
A Flutter Widget to make interactive timeline widget.

Bubble Timeline Package A Flutter Widget to make interactive timeline widget. This widget can be used to make Event Timelines, or Timelines for certai

Vansh Goel 12 Sep 22, 2022
📸 Easy to use yet very customizable zoomable image widget for Flutter, Photo View provides a gesture sensitive zoomable widget.

?? Easy to use yet very customizable zoomable image widget for Flutter, Photo View provides a gesture sensitive zoomable widget. Photo View is largely used to show interacive images and other stuff such as SVG.

Blue Fire 1.7k Jan 7, 2023
A widget lib that the widget in this lib can react to flutter ScrollController's offset

Language: English | 中文简体 linked_scroll_widgets A lib full of widgets that can react to the scrollController's offset change,to custom your UI effect.

WenJingRui 8 Oct 16, 2022
Full customable rolling switch widget for flutter apps based on Pedro Massango's 'crazy-switch' widget

lite_rolling_switch Full customable rolling switch widget for flutter apps based on Pedro Massango's 'crazy-switch' widget https://github.com/pedromas

Eduardo Muñoz 48 Dec 1, 2022
Progress Dialog widget for flutter projects with ability to customize loading widget, background color and background blur.

DISCONTINUED Checkout ArsDialog ars_progress_dialog Customizable progress dialog for Flutter applications with smooth animation for background dim col

Arsam 8 Apr 15, 2022
A Flutter widget that will give a Glitch Animation Effect to it's child widget.

GlitchEffect A Flutter widget that will give a Glitch Animation Effect to it's child widget. Installation Add the latest version of package to your pu

Sameer Singh 6 Nov 25, 2022
Widget, that can make any static located widget hidable

Installing See the official installing guidline from hidable/install Usage & Overview To start using Hidable widget, we have to create a ScrollControl

Anon 18 Dec 16, 2022
A widget that allow user resize the widget with drag

Flutter-Resizable-Widget A widget that allow user resize the widget with drag Note: this widget uses Getx Example bandicam.2021-11-11.12-34-41-056.mp4

MohammadAminZamani.afshar 22 Dec 13, 2022
⌚️ A general flutter timeline widget based on real-world application references

framework platform tags title flutter Android, iOS, Web, macOS, Linux, Windows flutter, timeline, flutter timeline, timeline tile flutter timeline flu

Universe 285 Dec 21, 2022
The color of the widget is different with the counter application

GoldenTestのお試しをしてみた https://pub.dev/packages/golden_toolkit このライブラリを使って、検証する ちなみにマスターのスクリーンショットをGoldenというらしい。 カウンターアプリでWidgetのカラーが違う場合をテストしてみた OK想定 NG

MatsumaruTsusyoshi 0 Oct 18, 2021
Flutter Carousel Pro - A Flutter Carousel widget

Carousel Extended A Flutter Carousel widget. Usage As simple as using any flutter Widget. Based on Carousel Pro but extended to be able to navigate be

omid habibi 3 Dec 7, 2020
🟥 A flutter widget that flashes when flutter fails to render a frame in a certain timeframe

?? A flutter widget that flashes when flutter fails to render a frame in a certain timeframe

Andrei Lesnitsky 32 Oct 8, 2022
React hooks for Flutter. Hooks are a new kind of object that manages a Widget life-cycles. They are used to increase code sharing between widgets and as a complete replacement for StatefulWidget.

English | Português Flutter Hooks A Flutter implementation of React hooks: https://medium.com/@dan_abramov/making-sense-of-react-hooks-fdbde8803889 Ho

Remi Rousselet 2.6k Dec 29, 2022
A simple Flutter widget library that helps us to select days in a week.

A simple Flutter widget library that helps us to select days in a week.

Shan Shaji 4 Oct 9, 2022