Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #40 Absence of focus node in credit_card_form.dart #65

Merged
merged 1 commit into from
Oct 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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';