adar2378 / pin_code_fields

A flutter package which will help you to generate pin code fields with beautiful design and animations. Can be useful for OTP or pin code inputs 🤓🤓
https://pub.dev/packages/pin_code_fields
MIT License
690 stars 336 forks source link

Set State is being called after disposed from Animation/Timer callback #302

Closed shaurya-src closed 10 months ago

shaurya-src commented 1 year ago

On changing the state of the screen with PinCodeTextField, this error is being thrown:

======== Exception caught by foundation library ====================================================
The following assertion was thrown while dispatching notifications for FocusNode:
setState() called after dispose(): _PinCodeTextFieldState#28fbb(lifecycle state: defunct, not mounted, tickers: tracking 0 tickers)

This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback.

The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree.
This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose().
bambinoua commented 1 year ago

It looks like this issue was fixed but version is not updated on pub.dev.

bambinoua commented 1 year ago

@adar2378 please update the version on pub.dev.

esentis commented 1 year ago

Do we have an ETA for the update ? :)

subzero911 commented 1 year ago

+1, need this fix

I currently have the similar error, when I show and hide the pin field while requesting the focus:

image

and mounted checking should solve it

bambinoua commented 1 year ago

For now the only "fix" is:

dependency_overrides:
  pin_code_fields:
    git:
      url: https://github.com/adar2378/pin_code_fields.git
      ref: master
stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

esentis commented 1 year ago

This is still not updated.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

esentis commented 1 year ago

Commenting for activity. The issue is still here.

subzero911 commented 1 year ago

Seems like an author had abandoned this package... Is anyone here who's willing to fork it and continue supporting?

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

bambinoua commented 1 year ago

@adar2378 we hope the new 8.0.1 version had fixed this issue? :)

adar2378 commented 1 year ago

@subzero911 I have not abandoned it. I am looking for maintainers if someone is interested because I have been busy with life and can not find enough time to implement/fix things quickly enough.

@bambinoua Yes, 8.0.1 should fix it.

stale[bot] commented 10 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.