From 6ccf0c543487107f6728f851e34e2628290ec094 Mon Sep 17 00:00:00 2001 From: Meet Janani Date: Tue, 28 Sep 2021 15:01:06 +0530 Subject: [PATCH] :bug: #40 Absence of focus node in credit_card_form.dart => As card number is the first field so it doesn't require focus node --- example/lib/main.dart | 4 ++-- lib/credit_card_form.dart | 1 - lib/credit_card_widget.dart | 22 +++++++++---------- ..._image.dart => custom_card_type_icon.dart} | 4 ++-- lib/flutter_credit_card.dart | 2 +- 5 files changed, 16 insertions(+), 17 deletions(-) rename lib/{custom_card_type_image.dart => custom_card_type_icon.dart} (80%) diff --git a/example/lib/main.dart b/example/lib/main.dart index 396caa3..2b44194 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -77,8 +77,8 @@ class MySampleState extends State { useBackgroundImage ? 'assets/card_bg.png' : null, isSwipeGestureEnabled: true, onCreditCardWidgetChange: (CreditCardBrand creditCardBrand) {}, - customCardIcons: [ - CustomCardTypeImage( + customCardTypeIcons: [ + CustomCardTypeIcon( cardType: CardType.mastercard, cardImage: Image.asset( 'assets/mastercard.png', diff --git a/lib/credit_card_form.dart b/lib/credit_card_form.dart index 1ea5f28..da10df8 100644 --- a/lib/credit_card_form.dart +++ b/lib/credit_card_form.dart @@ -90,7 +90,6 @@ class _CreditCardFormState extends State { MaskedTextController(mask: '0000'); FocusNode cvvFocusNode = FocusNode(); - FocusNode cardNumberNode = FocusNode(); FocusNode expiryDateNode = FocusNode(); FocusNode cardHolderNode = FocusNode(); diff --git a/lib/credit_card_widget.dart b/lib/credit_card_widget.dart index 73cfd9a..0ba9137 100644 --- a/lib/credit_card_widget.dart +++ b/lib/credit_card_widget.dart @@ -5,7 +5,7 @@ import 'package:flutter/material.dart'; import 'credit_card_animation.dart'; import 'credit_card_background.dart'; import 'credit_card_brand.dart'; -import 'custom_card_type_image.dart'; +import 'custom_card_type_icon.dart'; import 'glassmorphism_config.dart'; const Map CardTypeIconAsset = { @@ -38,7 +38,7 @@ class CreditCardWidget extends StatefulWidget { this.glassmorphismConfig, this.isChipVisible = true, this.isSwipeGestureEnabled = true, - this.customCardIcons = const [], + this.customCardTypeIcons = const [], required this.onCreditCardWidgetChange}) : super(key: key); @@ -65,7 +65,7 @@ class CreditCardWidget extends StatefulWidget { final String labelExpiredDate; final CardType? cardType; - final List customCardIcons; + final List customCardTypeIcons; @override _CreditCardWidgetState createState() => _CreditCardWidgetState(); @@ -527,9 +527,9 @@ class _CreditCardWidgetState extends State } Widget getCardTypeImage(CardType? cardType) { - final List customCardImage = getCustomCardTypeIcon(cardType!); - if(customCardImage.isNotEmpty){ - return customCardImage.first.cardImage; + final List customCardTypeIcon = getCustomCardTypeIcon(cardType!); + if(customCardTypeIcon.isNotEmpty){ + return customCardTypeIcon.first.cardImage; } else { return Image.asset( CardTypeIconAsset[cardType]!, @@ -545,7 +545,7 @@ class _CreditCardWidgetState extends State Widget getCardTypeIcon(String cardNumber) { Widget icon; final CardType ccType = detectCCType(cardNumber); - final List customCardTypeIcon = getCustomCardTypeIcon(ccType); + final List customCardTypeIcon = getCustomCardTypeIcon(ccType); if (customCardTypeIcon.isNotEmpty) { icon = customCardTypeIcon.first.cardImage; isAmex = ccType == CardType.americanExpress; @@ -604,10 +604,10 @@ class _CreditCardWidgetState extends State return icon; } - List getCustomCardTypeIcon(CardType currentCardType) => - widget.customCardIcons - .where((CustomCardTypeImage element) => - element.cardType == currentCardType) + List getCustomCardTypeIcon(CardType currentCardType) => + widget.customCardTypeIcons + .where((CustomCardTypeIcon element) => + element.cardType == currentCardType) .toList(); } diff --git a/lib/custom_card_type_image.dart b/lib/custom_card_type_icon.dart similarity index 80% rename from lib/custom_card_type_image.dart rename to lib/custom_card_type_icon.dart index e4328b5..40528b4 100644 --- a/lib/custom_card_type_image.dart +++ b/lib/custom_card_type_icon.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_credit_card/credit_card_widget.dart'; -class CustomCardTypeImage { - CustomCardTypeImage({ +class CustomCardTypeIcon { + CustomCardTypeIcon({ required this.cardType, required this.cardImage, }); diff --git a/lib/flutter_credit_card.dart b/lib/flutter_credit_card.dart index 296ad58..a1d6efe 100644 --- a/lib/flutter_credit_card.dart +++ b/lib/flutter_credit_card.dart @@ -4,4 +4,4 @@ export 'credit_card_form.dart'; export 'credit_card_model.dart'; export 'credit_card_widget.dart'; export 'glassmorphism_config.dart'; -export 'custom_card_type_image.dart'; +export 'custom_card_type_icon.dart';