set method
Implementation
void set(List<String> pin) {
final textFieldLength = _otpTextFieldState.widget.length;
if (pin.length < textFieldLength) {
throw new Exception(
"Pin length must be same as field length. Expected: $textFieldLength, Found ${pin.length}");
}
_otpTextFieldState._pin = pin;
String newPin = '';
final textControllers = _otpTextFieldState._textControllers;
for (int i = 0; i < textControllers.length; i++) {
final textController = textControllers[i];
final pinValue = pin[i];
newPin += pinValue;
if (textController != null) {
textController.text = pinValue;
}
}
final widget = _otpTextFieldState.widget;
if (widget.onChanged != null) {
widget.onChanged!(newPin);
}
if (widget.onCompleted != null) {
widget.onCompleted!(newPin);
}
}