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

Default validation of text fields other than card number not working #138

Closed
kazy-dev opened this issue May 12, 2023 · 2 comments · Fixed by #147
Closed

Default validation of text fields other than card number not working #138

kazy-dev opened this issue May 12, 2023 · 2 comments · Fixed by #147

Comments

@kazy-dev
Copy link

kazy-dev commented May 12, 2023

Thanks for all the maintenance you do.
Thanks for a very nice package.

I found this package and tried to incorporate it into an app I am developing.
However, I implemented CreditCardForm in the following environment and the default validation did not work for all text fields except card number.

Execution Environment

  • flutter_credit_card: ^3.0.6
  • Flutter 3.7.3 - channel stable - https://github.com/flutter/flutter.git
  • Framework - revision 9944297138 (3 months ago) - 2023-02-08 15:46:04 -0800
  • Engine - revision 248290d6d5
  • Tools - Dart 2.19.2 - DevTools 2.20.1
  • device: Android 13 pixel5a

For clarity of behavior,
autovalidateMode: AutovalidateMode.always.
setting, but it made no difference.
Also, running formKey.currentState!.validate() did not work except for the card number.

All validator arguments are omitted, and default processing should be performed inside the package, but I could not find the cause.

However, I launched the sample app in the /example folder in the package and all validation by button tap worked fine.
Sorry, I am not sure how to fix the problem. I could not find any difference.

screenshot

A screenshot is attached.
The only text field I am entering is the expiration date, which has an invalid value of 00/00.
Other than that, the card number, CVC, and card name are not entered and hint text is displayed.

スクリーンショット 2023-05-13 1 13 46

I await your reply, even if it is trivial, if you notice anything.
Thank you for your valuable input.
Best regards

@kazy-dev
Copy link
Author

kazy-dev commented May 12, 2023

Also, running formKey.currentState!.validate() did not work except for the card number.

As I wrote, I had all of the following set in CreditCardForm, but formKey.currentState!.validate() only worked for the card number text field if I had all of the following values set

CreditCardForm initial arguments
    required this.formKey, this.cardNumberKey, this.formKey.currentState!
    this.cardNumberKey, this.cardHolderKey, this.cardNumberKey
    this.cardHolderKey, this.expiryDateKey
    this.expiryDateKey, this.expiryDateKey, this.cvvCodeKey
    this.cvvCodeKey, this.cvvCodeKey, this.cvvCodeKey
 ..

But if I leave formKey alone and call formKey.currentState!.validate(), the validation of all text fields, including the card number text field, is enabled.

However, previously I could not figure out how to make the validation work except for the card number in the case of AutovalidateMode.always or AutovalidateMode.onUserInteraction.

@aditya-chavda
Copy link
Collaborator

Hey @kazy-dev,

I'm delighted to hear that you find this package to be very nice and well-maintained.

Thank you for raising this issue. I wanted to inform you that I've initiated a pull request (PR) to resolve the issue you mentioned. Please try out that branch and let me know if you still face the issue. You can find the PR here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants