onChange method
dynamic
onChange(
{ - required int currentIndex,
})
Implementation
onChange({
required int currentIndex,
}) {
final ct = otpFieldControllers[currentIndex];
// if (currentIndex > 0) {}
if (ct.text.isEmpty) {
_removeText();
if (currentIndex > 0) {
focusNodes[currentIndex - 1].requestFocus();
}
} else {
_addText(ct.text);
if (currentIndex < widget.otpCount - 1) {
focusNodes[currentIndex + 1].requestFocus();
} else {
focusNodes[currentIndex].unfocus();
widget.onSubmit!(controller.text);
}
}
}