Reputation: 519
I am using otp_text_field package where user can type there otp. When I start typing on the first box it shows me this error TypeErrorImpl was thrown while calling onChanged, Unexpected null value. below is my code:-
Expanded(
child: Column(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
children: [
OTPTextField(
length: 4,
width: 250,
fieldWidth: 35,
style: const TextStyle(fontSize: 17),
textFieldAlignment:
MainAxisAlignment.spaceAround,
fieldStyle: FieldStyle.underline,
onCompleted: (pin) {
print("Completed: " + pin);
},
),
Upvotes: 0
Views: 224
Reputation: 26
There is a bug in the package that you are using. I saw, that you created an issue there, but you are not the first who faced this bug, so there is already a pull request, that fixed this. You could comment there, so the author will see that more devs are blocked by this.
Before this PR is merged and a new version of the package is published by the package author, you could use the forked version or fork it by yourself and fix bugs that block you. The second option (fork by yourself) is preferable, coz the author of the original PR could delete his fork, so you will be unable to continue developing unexpectedly. Usage of git dependencies is documented here.
If you prefer using git dependency, I recommend checking the package from time to time, so as soon as one of the PRs is merged, you could change the dependency to the original package from pub dev, so you will get new features and fixes.
But I'm not thinking that that will happens any time soon. As I see, there is an almost 1-year-old PR, that fixes the same issue, and it is still not merged, so the package is not maintained well and maybe you should look for more supported alternatives.
UPD: To fork a package, you need to to the package repo page on GitHub and press the fork button. After that, you will be asked to fill a couple of fields and a fork will be created.
To depend your project on a fork instead of the original pub dev package, you will need to update pubspec.yaml with something like this. More details you could get from the documentation of git dependencies, that i mentioned earlier
otp_text_field:
git:
url: insert link to your fork here
ref: commit hash or branch name here
Upvotes: 1