SimformSolutionsPvtLtd / flutter_credit_card

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

keyboardType: TextInputType.number not working on iOS for cardNumber #126

Closed baptistesx closed 1 year ago

baptistesx commented 1 year ago

Heyy! I have no clue why keyboardType: TextInputType.number is not working on iOS for cardNumber. It is working as expected on android. Here is a demo:

https://user-images.githubusercontent.com/9638281/215932899-e6fc9a41-cfa7-4ec1-b511-56bb86b0b7a7.mov

I can see in the package code /flutter_credit_card-3.0.5/lib/credit_card_form.dart line 194, the keyboardType prop is well setup image

Any idea?

adamcastleman commented 1 year ago

AutofillHints.creditCardNumber overrides and displays number + options. Delete the autofill hint variable entirely and the keyboard type will display just the numbers.

Use the hintText under the InputDecoration if you still need the hint.

baptistesx commented 1 year ago

thanks @adamcastleman for your answer.

You mean remove it like this? image

But it's in the packge, i cannot touch it, except if if copy it locally but then it won't be linked to pub anymore, that's not good. Or i miss something?

adamcastleman commented 1 year ago

Right - you could copy to a local file. The form is just a StatefulWidget. It would still interact with the card widget.

You do lose access to pub updates. This may not really be all bad for the form - how often does a form entering CC info need to radically change?

You could also file a pull request and change the hardcoded value to softcode and feed it into the widget.

Or hopefully, a package manager is seeing this and can submit a pull request themselves.

The number + options was just annoying enough for me to decide to copy over the form. It also let me clean it up. You'll have to decide for your own app.

baptistesx commented 1 year ago

Thank you, it took me 45s! I hope one day, i'll have time to do a PR...