Code Monkey home page Code Monkey logo

flutter_credit_card's Introduction

banner

Flutter Credit Card

build flutter_credit_card

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

Preview

Glassmorphism and Card Background
The example app showing credit card widget
Floating Card on Mobile
The example app showing card floating animation in mobile
Floating Card on Web
The example app showing card floating animation in web

Migration guide for Version 4.x.x

  • The themeColor, textColor, and cursorColor properties have been removed from CreditCardForm due to changes in how it detects and applies application themes. Please check out the example app to learn how to apply those using Theme.
  • The cardNumberDecoration, expiryDateDecoration, cvvCodeDecoration, and cardHolderDecoration properties are moved to the newly added InputDecoration class that also has textStyle properties for all the textFields of the CreditCardForm.

Installing

  1. Add dependency to pubspec.yaml

    Get the latest version from the 'Installing' tab on pub.dev

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
      onCreditCardWidgetChange: (CreditCardBrand brand) {}, // Callback for anytime credit card brand is changed
    ),

With optional parameters

    CreditCardWidget(
      cardNumber: cardNumber,
      expiryDate: expiryDate,
      cardHolderName: cardHolderName,
      cvvCode: cvvCode,
      showBackView: isCvvFocused,
      onCreditCardWidgetChange: (CreditCardBrand brand) {},
      bankName: 'Name of the Bank',
      cardBgColor: Colors.black87,
      glassmorphismConfig: Glassmorphism.defaultConfig(),
      enableFloatingCard: true,
      floatingConfig: FloatingConfig(
        isGlareEnabled: true,
        isShadowEnabled: true,
        shadowConfig: FloatingShadowConfig(),
      ),
      backgroundImage: 'assets/card_bg.png',
      backgroundNetworkImage: 'https://www.xyz.com/card_bg.png',
      labelValidThru: 'VALID\nTHRU',
      obscureCardNumber: true,
      obscureInitialCardNumber: false,
      obscureCardCvv: true,
      labelCardHolder: 'CARD HOLDER',
      labelValidThru: 'VALID\nTHRU',
      cardType: CardType.mastercard,
      isHolderNameVisible: false,
      height: 175,
      textStyle: TextStyle(color: Colors.yellowAccent),
      width: MediaQuery.of(context).size.width,
      isChipVisible: true,
      isSwipeGestureEnabled: true,
      animationDuration: Duration(milliseconds: 1000),
      frontCardBorder: Border.all(color: Colors.grey),
      backCardBorder: Border.all(color: Colors.grey),
      chipColor: Colors.red,
      padding: 16,
      customCardTypeIcons: <CustomCardTypeIcons>[
        CustomCardTypeIcons(
          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,
          ],
        ),
      ),
    ),

Floating Card

  • Default Configuration
    CreditCardWidget(
        enableFloatingCard: true,
    );
  • Custom Configuration
    CreditCardWidget(
        enableFloatingCard: true,
        floatingConfig: FloatingConfig(
            isGlareEnabled: true,
            isShadowEnabled: true,
            shadowConfig: FloatingShadowConfig(
              offset: Offset(10, 10),
              color: Colors.black84,
              blurRadius: 15,
            ),
        ),
    );

NOTE: Currently the floating card animation is not supported on mobile platform browsers.

  1. Adding CreditCardForm
    CreditCardForm(
      formKey: formKey, // Required 
      cardNumber: cardNumber, // Required
      expiryDate: expiryDate, // Required
      cardHolderName: cardHolderName, // Required
      cvvCode: cvvCode, // Required
      cardNumberKey: cardNumberKey,
      cvvCodeKey: cvvCodeKey,
      expiryDateKey: expiryDateKey,
      cardHolderKey: cardHolderKey,
      onCreditCardModelChange: (CreditCardModel data) {}, // Required
      obscureCvv: true, 
      obscureNumber: true,
      isHolderNameVisible: true,
      isCardNumberVisible: true,
      isExpiryDateVisible: true,
      enableCvv: true,
      cvvValidationMessage: 'Please input a valid CVV',
      dateValidationMessage: 'Please input a valid date',
      numberValidationMessage: 'Please input a valid number',
      cardNumberValidator: (String? cardNumber){},
      expiryDateValidator: (String? expiryDate){},
      cvvValidator: (String? cvv){},
      cardHolderValidator: (String? cardHolderName){},
      onFormComplete: () {
      // callback to execute at the end of filling card data
      },
      autovalidateMode: AutovalidateMode.always,
      disableCardNumberAutoFillHints: false,
      inputConfiguration: const InputConfiguration(
        cardNumberDecoration: InputDecoration(
          border: OutlineInputBorder(),
          labelText: 'Number',
          hintText: 'XXXX XXXX XXXX XXXX',
        ),
        expiryDateDecoration: InputDecoration(
          border: OutlineInputBorder(),
          labelText: 'Expired Date',
          hintText: 'XX/XX',
        ),
        cvvCodeDecoration: InputDecoration(
          border: OutlineInputBorder(),
          labelText: 'CVV',
          hintText: 'XXX',
        ),
        cardHolderDecoration: InputDecoration(
          border: OutlineInputBorder(),
          labelText: 'Card Holder',
        ),
        cardNumberTextStyle: TextStyle(
          fontSize: 10,
          color: Colors.black,
        ),
        cardHolderTextStyle: TextStyle(
          fontSize: 10,
          color: Colors.black,
        ),
        expiryDateTextStyle: TextStyle(
          fontSize: 10,
          color: Colors.black,
        ),
        cvvCodeTextStyle: TextStyle(
          fontSize: 10,
          color: Colors.black,
        ),
      ),
    ),

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 flip animation is inspired from this Dribbble art.
  • This package's float animation is inspired from the Motion flutter package.

Main Contributors


Vatsal Tanna

Devarsh Ranpara

Kashifa Laliwala

Sanket Kachchela

Meet Janani

Shweta Chauhan

Kavan Trivedi

Ujas Majithiya

Aditya Chavda

Awesome Mobile Libraries

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.

flutter_credit_card's People

Contributors

aditya-css avatar bilonik avatar birjuvachhani avatar canoncul avatar cybex-dev avatar deanli586 avatar devarshranpara avatar devarshranpara-simformsolutions avatar dhavalrkansara avatar elforl avatar faiyaz-shaikh avatar guicarvalho avatar jlaskowska avatar kashifalaliwala avatar kavantrivedi avatar kika avatar meetjanani avatar meetjanani-simformsolutions avatar mobile-simformsolutions avatar ocakliemre avatar parthbaraiya avatar pranjal-barnwal avatar sanket-simform avatar shwetachauhan-simform avatar shwetachauhan18 avatar simform-solutions avatar tceccatto avatar ujas-m-simformsolutions avatar vatsaltanna avatar vhanda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

flutter_credit_card's Issues

Pass AutovalidateMode to CreditCardForm

Is your feature request related to a problem? Please describe.
Would like to change the AutovalidateMode in CreditCardForm

Describe the solution you'd like
Add optional AutovalidateMode input to CreditCardForm

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

Make detectCCType publicly accessible

On 0.1.3 detectCCType is not publicly accessible and there seems to be no method to detect card type by card number using your library even though the method is already in the library.

Support Auto-Fill Hints

Flutter now supports AutoFillHints. There's creditCardExpirationDate, creditCardExpirationYear, creditCardNumber, etc.

This would be a great addition to your library

Done does not unfocus keyboard

Describe the bug
When pressing done on iOS, the keyboard does nothing.
I tried to fork, but fork does not allow fields to be edited for some reason.

To Reproduce
Install, enter fields info, try to press done on iOS simulator.

Expected behaviour
It should close the keyboard.

Issue Report ... Feature request

Firstly: when you click on any field the keyboard appears then disappears again and i lose the focus !, sounds like there's a timer makes setState((){}); every second .. you should fix it by letting us control the setstate steps..

Secondly: you should support dark mode, and respect the device them mode because when i convert to the dark mode in the device i see dark layer hides the content !

please do it directly, thank you.

change labelText and hintText

example

InputDecoration(
                  border: OutlineInputBorder(),
                  labelText: 'Card number',
                  hintText: 'xxxx xxxx xxxx xxxx',
                );
InputDecoration(
                  border: OutlineInputBorder(),
                  labelText: 'Numero de tarjeta',
                  hintText: 'xxxx xxxx xxxx xxxx',
                )

make getCardTypeIcon accessible (public)

I would like to detect card type icon to display it in a custom container.

making getCardTypeIcon public and static would be great.

An alternative could be to allow us to listen when card type icon change to use it and display it on other places too.

image

Expiry date with validation helper not aligned with valid CVV

Describe the bug
When the expiry date of a card is invalid, but the CVV is valid, the helptext underneath the expiry date nudges it out of alignment with the CVV text field.

To Reproduce
Steps to reproduce the behavior:

  1. Instantiate a CreditCardForm
  2. Purposefully introduce an invalid expiry date, but valid CVV
  3. Validate.

Expected behavior
Expiry date and CVV always aligned, regardless of validation errors

Screenshots
image

Desktop (please complete the following information):
-Windows 11

Smartphone (please complete the following information):
-Android Emulator. Pixel 4a

Comments
Not a particularly terrible issue, but I would still consider this a visual bug.
The fix would probably be as simple as setting crossAxisAlignment on the row containing both expiry date and cvv fields.

Provide builders

Providing builders for:

  • chip icon
  • brand icon

would furnish a more idiomatic API and an easier maintainability for the library.

This would be a breaking change but since #115 requires a major bump now would be the time if that one passes

Package doesn't work when imported `as`

Describe the bug

If the package is imported as the CreditCardModel class becomes invisible due to the lack of explicit export.

To Reproduce
Steps to reproduce the behavior:

  1. import 'package:flutter_credit_card/flutter_credit_card.dart' as CC;
  2. void foo(CC.CreditCardModel m)
  3. Syntax error
  4. PROFIT???!!

Expected behavior
Ability to use CreditCardModel through named import.

Absence of focus node in credit_card_form.dart

Bug
First and foremost thanks for this package. It was very helpful for my use-case, however when I tried to customize 'credit_card_form.dart' file, I found out that there was no focus node associated with 'cardNumber' textformfield, also disposal of this node ('cardNumberNode') was missing in the 'dispose' function.

Container( padding: const EdgeInsets.symmetric(vertical: 8.0), margin: const EdgeInsets.only(left: 16, top: 16, right: 16), child: TextFormField( obscureText: widget.obscureNumber, controller: _cardNumberController, cursorColor: widget.cursorColor ?? themeColor, onEditingComplete: () { FocusScope.of(context).requestFocus(expiryDateNode); }, style: TextStyle( color: widget.textColor, ), decoration: widget.cardNumberDecoration, keyboardType: TextInputType.number, textInputAction: TextInputAction.next, validator: (String value) { // Validate less that 13 digits +3 white spaces if (value.isEmpty || value.length < 16) { return widget.numberValidationMessage; } return null; }, ), ),

@override void dispose() { cardHolderNode.dispose(); cvvFocusNode.dispose(); expiryDateNode.dispose(); super.dispose(); }

need to insert focusNode: cardHolderNode, and cardNumberNode.dispose(); in lib/credit_card_form.dart (lines, between 177 - 196 and lines 150 - 155 respectively as per github (master)) otherwise, the package worked fine. Feel free to close this issue if insignificant.

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

Leave customizable field names

It could be possible to change the name of the fields, for example, I live in Brazil, and all plugin field names are in English, it could be possible to change the display name of the fields

Adding customization to any validator of a TextField

At first, I wanted to find a way to somehow trigger showing the error message of Card Number TextField but couldn't so then I wanted to add an extra control or validation to the card number input but didn't find a possible way, unfortunately. Because the validator is directly written inside the TextField and not available for customization.

I would like to find a way where I can

  1. Add a custom validator to each TextField.
  2. Add a bool value to the validator.
  3. Make my own check/control in my app and somehow be able to trigger showing the error message for any TextField.

cardBgColor is correct on app only, and the CreditCardWidget vertical height is stretched on Desktop web, but not mobile web

CreditCardWidget in app

image

CreditCardWidget on Desktop Chrome 101 on Linux web

image

CreditCardWidget on Chrome mobile web

image

My CreditCardWidget and CreditCardForm code. Also, the cardBgColor: kAvailableSeat, referenced is const Color kAvailableSeat = Color(0xFF162A52);.

SizedBox(
  width: 500,
  child: CreditCardWidget(
    cardNumber: cardNumber,
    expiryDate: expiryDate,
    cardHolderName: cardHolderName,
    cvvCode: cvvCode,
    showBackView: isCvvFocused,
    obscureCardNumber: true,
    obscureCardCvv: true,
    isHolderNameVisible: true,
    cardBgColor: kAvailableSeat,
    isSwipeGestureEnabled: true,
    onCreditCardWidgetChange:
        (CreditCardBrand
            creditCardBrand) {},
  ),
),
ConstrainedBox(
  constraints: const BoxConstraints(
    maxWidth: 500,
  ),
  child: CreditCardForm(
    formKey: _creditCardFormKey,
    obscureCvv: true,
    obscureNumber: true,
    cardNumber: cardNumber,
    cvvCode: cvvCode,
    isHolderNameVisible: true,
    isCardNumberVisible: true,
    isExpiryDateVisible: true,
    cardHolderName: cardHolderName,
    expiryDate: expiryDate,
    themeColor: kAvailableSeat,
    textColor: kAvailableSeat,
    cardNumberDecoration:
        kInputStringFields.copyWith(
      hintText:
          'XXXX XXXX XXXX XXXX',
      labelText: 'Number',
    ),
    expiryDateDecoration:
        kInputStringFields.copyWith(
      hintText: 'MMYY',
      labelText: 'Expired Date',
    ),
    cvvCodeDecoration:
        kInputStringFields.copyWith(
      hintText: 'XXX',
      labelText: 'CVV',
    ),
    cardHolderDecoration:
        kInputStringFields.copyWith(
      hintText: 'Card holder name',
      labelText: 'Card Holder',
    ),
    onCreditCardModelChange:
        onCreditCardModelChange,
  ),
),

Desktop

  • Chrome 101 on Linux

Smartphone

  • Pixel 6 Chrome

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/

'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:

Credit.Card.Form.Issue.mp4

The device I use for testing

  • iphone11
  • ioS 14.5

Handle changes of values in didChangeDependencies of CreditCardForm

Initializing values is done in this method createCreditCardModel(), and it's being called only in initState().

I believe this method should also be called in didChangeDependencies() method as well to reflect the new changes of
cardNumber
expiryDate
cardHolderName
cvvCode

Remove dead code

  1. There is a bunch of dead code in the library that is exported in the public API. I'm thinking about LocalizedTextModel which is used only by the tests but there might be a few other stuff.

  2. Everything is exported in the public api too, some things could be encapsulated, which is achieved by having a structure like this:

  - /src
     - private_stuff.dart
     - something.dart
  - flutter_credit_card.dart // exports something.dart

Quite frankly the library could do with some more cleaning, it would go a long way to help us make pull requests.

Card Type Logos inconsistent styling. Can we specify a custom logo?

I get feedback from clients that the Visa Logo looks 'incorrect' and not what they expect, or up to standard. It does look slightly worse than others due to the white background.

Without having the burden to keep every logo up to date yourselves, can you allow developers to specify an asset image they would like to put in replacement?

An alternative would be to change the visa logo.

Save CardType

I tried a lot but didn't find any way to save the card type in my firebase.
Can you please help me to save cardType in my firebase firestore?????

card form issue

Hello where is this two file located or i have to create them?

import 'package:flutter_credit_card/credit_card_form.dart';
import 'package:flutter_credit_card/credit_card_model.dart';
this file show target of uri does not exist, Do i need to created it manually or it's there in package?

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

Screen.Recording.2022-02-08.at.10.58.34.AM.mov
  • iOS simulator
  • iOS version - 15.2
  • Flutter version - 2.10.0

Add tests

Making sure a library such as one dealing with an important aspect such as credit card does not break, is important.

The minimum would be:

  • do the widget render without error
  • are the correct values displayed
  • is the correct error message shown on invalid data

Currently the only test the library provides is for a class that's not used anywhere.

This would help a lot when making a Pull request to make sure nothing broke.

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

Unable to load bundled icons

Unable to load asset: packages/flutter_credit_card/icons/visa.png #0 PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:237:7) <asynchronous suspension> #1 AssetBundleImageProvider._loadAsync (package:flutter/src/painting/image_provider.dart:675:14) <asynchronous suspension>

Simulator Screen Shot - iPhone 13 - 2022-01-18 at 04 56 37

-OS iOS
-Version 15

Bank name above card number

I'm using this package and one thing that it don't contains is bank name above card number. I'm find similar package that contains this feature.

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?

Form Card Visibility

Could you include the option to select specific FormsCards fields? I would like to leave only the CVV field visible to prompt the user to type in validation. If he wants to change the card, I release all fields. Do you understand?

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;

Make CARD HOLDER optional

I was looking for a way to hide card holder name in the widget.

To get it done, I pass a white space (" ") as param in cardHolderName property.

It would be great having an option to hide it.

Thanks

textfield validation

I'm using this package and it works very well but I can fill the fields without any validation how can I make a validation check for this package?

ThemeData not applied to Credit Card Form

Hello, thanks for making this its really cool.

But I have ThemeData in my app that includes inputDecorationTheme for all inputs in my app

but this package doesn't use my theme data

is this a feature that needs to be created in this package, or is there a way for me to override the packages input decorations with my app's ThemeData

2 cards are visible but 1 is 90° rotated

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Used example on github

Expected behavior

2 cards make an X on y-axes

I can't change label color on floating.

Hi, my problem is changing the label color on floating mode. The default floating label color is blue and I could'nt change it.

Here it is how my credit card form looks.
Screen Shot 2021-07-21 at 14 18 27

Here is my source code

`import 'package:flutter/material.dart';
import 'package:flutter_credit_card/credit_card_model.dart';
import 'package:flutter_credit_card/flutter_credit_card.dart';
import 'package:get/get.dart';
import 'package:mawqeay/helper/ui_helper.dart';

import '../../../theme.dart';

class CodeCreditCardPayment extends StatefulWidget {
@OverRide
State createState() {
return CodeCreditCardPaymentState();
}
}

class CodeCreditCardPaymentState extends State {
String cardNumber = '';
String expiryDate = '';
String cardHolderName = '';
String cvvCode = '';
bool isCvvFocused = false;
final GlobalKey formKey = GlobalKey();

@OverRide
Widget build(BuildContext context) {
OutlineInputBorder _inputBorder = OutlineInputBorder(
borderSide: BorderSide(
color: inputBorderColor,
width: 1.0,
),
borderRadius: widget.borderRadius8,
gapPadding: 4.0);
return Scaffold(
resizeToAvoidBottomInset: true,
body: SafeArea(
child: Column(
children: [
CreditCardWidget(
cardNumber: cardNumber,
expiryDate: expiryDate,
cardHolderName: cardHolderName,
cvvCode: cvvCode,
showBackView: isCvvFocused,
obscureCardNumber: true,
obscureCardCvv: true,
cardBgColor: Get.theme.primaryColor,
),
Expanded(
child: SingleChildScrollView(
child: Column(
children: [
CreditCardForm(
formKey: formKey,
obscureCvv: true,
obscureNumber: true,
cardNumber: cardNumber,
cvvCode: cvvCode,
cardHolderName: cardHolderName,
expiryDate: expiryDate,
themeColor: Get.theme.primaryColor,
cardNumberDecoration: InputDecoration(
border: _inputBorder,
floatingLabelBehavior: FloatingLabelBehavior.auto,
enabledBorder: _inputBorder,
focusedBorder: _inputBorder.copyWith(
borderSide: BorderSide(
width: 2.0, color: Get.theme.primaryColor)),
labelText: 'Number',
hintText: 'XXXX XXXX XXXX XXXX',
),
expiryDateDecoration: InputDecoration(
border: _inputBorder,
enabledBorder: _inputBorder,
focusedBorder: _inputBorder.copyWith(
borderSide: BorderSide(
width: 2.0, color: Get.theme.primaryColor)),
labelText: 'Expired Date',
hintText: 'XX/XX',
),
cvvCodeDecoration: InputDecoration(
border: _inputBorder,
enabledBorder: _inputBorder,
focusedBorder: _inputBorder.copyWith(
borderSide: BorderSide(
width: 2.0, color: Get.theme.primaryColor)),
labelText: 'CVV',
hintText: 'XXX',
),
cardHolderDecoration: InputDecoration(
border: _inputBorder,
enabledBorder: _inputBorder,
focusedBorder: _inputBorder.copyWith(
borderSide: BorderSide(
width: 2.0, color: Get.theme.primaryColor)),
labelText: 'Card Holder',
),
onCreditCardModelChange: onCreditCardModelChange,
),
ElevatedButton(
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: widget.borderRadius8,
),
primary: Get.theme.primaryColor,
),
child: Container(
margin: const EdgeInsets.all(8),
child: const Text(
'Continue',
style: TextStyle(
color: Colors.white,
fontFamily: 'halter',
fontSize: 14,
package: 'flutter_credit_card',
),
),
),
onPressed: () {
/if (formKey.currentState!.validate()) {
print('valid!');
} else {
print('invalid!');
}
/
},
)
],
),
),
),
],
),
),
);
}

void onCreditCardModelChange(CreditCardModel? creditCardModel) {
setState(() {
cardNumber = creditCardModel!.cardNumber;
expiryDate = creditCardModel.expiryDate;
cardHolderName = creditCardModel.cardHolderName;
cvvCode = creditCardModel.cvvCode;
isCvvFocused = creditCardModel.isCvvFocused;
});
}
}
`
Thanks!

Card background image

file path:
..\flutter.pub-cache\hosted\pub.dartlang.org\flutter_credit_card-3.0.1\lib\credit_card_background.dart
line: 45

change it to:

 image: backgroundImage==null||backgroundImage!.trim()==''?null:
                     backgroundImage!=null&&(backgroundImage!).toString().toLowerCase().startsWith('http')?
                     DecorationImage(image:NetworkImage(backgroundImage!),fit:BoxFit.fill)
                     :
                     DecorationImage(image:ExactAssetImage(backgroundImage!),fit:BoxFit.fill),
                     ),

to support images from internet., not assets only, it's very important update, thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.