adar2378 / pin_code_fields

A flutter package which will help you to generate pin code fields with beautiful design and animations. Can be useful for OTP or pin code inputs 🤓🤓
https://pub.dev/packages/pin_code_fields
MIT License
677 stars 330 forks source link

autofocus on PinCodeTextField with keyboard on initial screen #374

Closed kandangit closed 3 months ago

kandangit commented 3 months ago

I set autofocus property: to true.

I would like that the keyboard automatically pops up, like it does when autofocus is set to true in a TextFormField widget.

Is there any workaround or fix so, whenever the PinCodeTextField loads, the keyboard appears without needing to manually press the pin code field to start writing?.

Using the currently latest version of the plugin (8.0.1)

kandangit commented 3 months ago

Closing this...

The issue persists but the problem I believe is in Flutter or in Android, I don't know.

The widget indded has the focus but the keyboard didn't popup since the screen was loaded "too" quick (first screen without any logic/waiting time before).

My workaround for now is to use an intermediate screen which displays a loading indicator and after a small timeout redirects to the PIN screen.

If it serves to anyone this is the redirection code. The initial route is the screen in which this code exists.


SchedulerBinding.instance.addPostFrameCallback((_) {
  Timer(const Duration(milliseconds: 100), () {
    Navigator.pushReplacementNamed(context, AppRoutes.getPinScreen().routerName);
  });
});