Auto Focus the first input field on building the the OtpTextField
Closed this issue · 1 comments
Masangula commented
Auto Focus the first input field on building the the OtpTextField
cadivus commented
This does the job for me:
SizedBox(
width: width,
child: Stack(
children: [
OTPTextField(
controller: otpController,
length: 6,
width: MediaQuery.of(context).size.width,
textFieldAlignment: MainAxisAlignment.spaceAround,
fieldWidth: 45,
fieldStyle: FieldStyle.underline,
outlineBorderRadius: 15,
style: TextStyle(fontSize: 17),
isDense: true,
onChanged: (newPin) {
pin = newPin;
print("Changed: " + pin);
},
onCompleted: (newPin) {
print("Completed: " + newPin);
},
),
GestureDetector(
onTap: () {
otpController.setFocus(min(5, pinn.length));
},
child: Container(
width: width,
height: 60,
color: Colors.transparent,
),
),
],
),
),