I am using this dart package otp_text_field 1.1.1.
OTPTextField(
length: 6,
width: MediaQuery.of(context).size.width,
fieldWidth: 30,
style: TextStyle(fontSize: 20),
textFieldAlignment: MainAxisAlignment.spaceAround,
fieldStyle: FieldStyle.underline,
onChanged: (pin) {
if (pin.length == 6) {
print("Changed: " + pin);
}
},
)
I get this error on the onChanged handler
The following _CastError was thrown while calling onChanged:
Null check operator used on a null value
When the exception was thrown, this was the stack
Not getting any idea on whats wrong.
Added Stacktrace -
_OTPTextFieldState.buildTextField.<anonymous closure>
package:otp_text_field/otp_field.dart:179
#1 EditableTextState._formatAndSetValue
package:flutter/…/widgets/editable_text.dart:2298
#2 EditableTextState.updateEditingValue
package:flutter/…/widgets/editable_text.dart:1749
#3 TextInput._handleTextInputInvocation
package:flutter/…/services/text_input.dart:1351
#4 MethodChannel._handleAsMethodCall
package:flutter/…/services/platform_channel.dart:435
onCompletedis null (i.e. you don't pass it as parameter). A related issue.