LiewJunTung / pin_code_text_field

A highly customisable Flutter widget for entering pin code. Suitable for use cases such as login and OTP.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AutoFocus is not Working

abumoallim opened this issue · comments

When the OTP page open, the keyboard should by default open and cursor for the first box should be selected.

and if keyboard is open already open from previous page, it should focus the first edittext without on it explicitly.

I've resolved same problem like this:

@OverRide
void initState() {
super.initState();
myFocusNode = new FocusNode();
WidgetsBinding.instance.addPostFrameCallback((_) => focusBug());
}

void focusBug() {
myFocusNode.unfocus();
FocusScope.of(context).requestFocus(myFocusNode);
}

@OverRide
void dispose() {
myFocusNode.dispose();
super.dispose();
}