Skip to content

Commit

Permalink
🐛 #40 Absence of focus node in credit_card_form.dart =>
Browse files Browse the repository at this point in the history
As card number is the first field so it doesn't require focus node
  • Loading branch information
meetjanani-simformsolutions authored and vatsaltanna committed Oct 11, 2021
1 parent 43ec16c commit 6ccf0c5
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions example/lib/main.dart
Expand Up @@ -77,8 +77,8 @@ class MySampleState extends State<MySample> {
useBackgroundImage ? 'assets/card_bg.png' : null,
isSwipeGestureEnabled: true,
onCreditCardWidgetChange: (CreditCardBrand creditCardBrand) {},
customCardIcons: <CustomCardTypeImage>[
CustomCardTypeImage(
customCardTypeIcons: <CustomCardTypeIcon>[
CustomCardTypeIcon(
cardType: CardType.mastercard,
cardImage: Image.asset(
'assets/mastercard.png',
Expand Down
1 change: 0 additions & 1 deletion lib/credit_card_form.dart
Expand Up @@ -90,7 +90,6 @@ class _CreditCardFormState extends State<CreditCardForm> {
MaskedTextController(mask: '0000');

FocusNode cvvFocusNode = FocusNode();
FocusNode cardNumberNode = FocusNode();
FocusNode expiryDateNode = FocusNode();
FocusNode cardHolderNode = FocusNode();

Expand Down
22 changes: 11 additions & 11 deletions lib/credit_card_widget.dart
Expand Up @@ -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<CardType, String> CardTypeIconAsset = <CardType, String>{
Expand Down Expand Up @@ -38,7 +38,7 @@ class CreditCardWidget extends StatefulWidget {
this.glassmorphismConfig,
this.isChipVisible = true,
this.isSwipeGestureEnabled = true,
this.customCardIcons = const <CustomCardTypeImage>[],
this.customCardTypeIcons = const <CustomCardTypeIcon>[],
required this.onCreditCardWidgetChange})
: super(key: key);

Expand All @@ -65,7 +65,7 @@ class CreditCardWidget extends StatefulWidget {
final String labelExpiredDate;

final CardType? cardType;
final List<CustomCardTypeImage> customCardIcons;
final List<CustomCardTypeIcon> customCardTypeIcons;

@override
_CreditCardWidgetState createState() => _CreditCardWidgetState();
Expand Down Expand Up @@ -527,9 +527,9 @@ class _CreditCardWidgetState extends State<CreditCardWidget>
}

Widget getCardTypeImage(CardType? cardType) {
final List<CustomCardTypeImage> customCardImage = getCustomCardTypeIcon(cardType!);
if(customCardImage.isNotEmpty){
return customCardImage.first.cardImage;
final List<CustomCardTypeIcon> customCardTypeIcon = getCustomCardTypeIcon(cardType!);
if(customCardTypeIcon.isNotEmpty){
return customCardTypeIcon.first.cardImage;
} else {
return Image.asset(
CardTypeIconAsset[cardType]!,
Expand All @@ -545,7 +545,7 @@ class _CreditCardWidgetState extends State<CreditCardWidget>
Widget getCardTypeIcon(String cardNumber) {
Widget icon;
final CardType ccType = detectCCType(cardNumber);
final List<CustomCardTypeImage> customCardTypeIcon = getCustomCardTypeIcon(ccType);
final List<CustomCardTypeIcon> customCardTypeIcon = getCustomCardTypeIcon(ccType);
if (customCardTypeIcon.isNotEmpty) {
icon = customCardTypeIcon.first.cardImage;
isAmex = ccType == CardType.americanExpress;
Expand Down Expand Up @@ -604,10 +604,10 @@ class _CreditCardWidgetState extends State<CreditCardWidget>
return icon;
}

List<CustomCardTypeImage> getCustomCardTypeIcon(CardType currentCardType) =>
widget.customCardIcons
.where((CustomCardTypeImage element) =>
element.cardType == currentCardType)
List<CustomCardTypeIcon> getCustomCardTypeIcon(CardType currentCardType) =>
widget.customCardTypeIcons
.where((CustomCardTypeIcon element) =>
element.cardType == currentCardType)
.toList();
}

Expand Down
@@ -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,
});
Expand Down
2 changes: 1 addition & 1 deletion lib/flutter_credit_card.dart
Expand Up @@ -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';

0 comments on commit 6ccf0c5

Please sign in to comment.