SimformSolutionsPvtLtd / flutter_credit_card

A credit card widget for Flutter application.
https://pub.dev/packages/flutter_credit_card
MIT License
417 stars 241 forks source link

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

Closed kazy-dev closed 11 months ago

kazy-dev commented 1 year ago

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

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 commented 1 year ago

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, butformKey.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 commented 1 year ago

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.