Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Track controller stream subscription and cancel on dispose #43

Closed
wants to merge 4 commits into from

Conversation

ltOgt
Copy link
Contributor

@ltOgt ltOgt commented Aug 17, 2024

Description

// init:
controllerSubscription = widget.controller?.events.listen(_controllerListener);

// dispose:
controllerSubscription?.cancel();

Related Issues

Fixes:

Unhandled Exception: This widget has been unmounted, so the State no longer has a context (and should be considered defunct).
Consider canceling any active work during "dispose" or using the "mounted" getter to determine if the State is still active.

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I updated pubspec.yaml with an appropriate new version according to the [pub versioning philosophy], or this PR is [exempt from version changes].
  • I updated CHANGELOG.md to add a description of the change, [following repository CHANGELOG style].
  • [-] I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.

Visual reference

No change

@ltOgt
Copy link
Contributor Author

ltOgt commented Aug 17, 2024

Not sure why the formatter is still failing the pipeline

@ricardodalarme
Copy link
Owner

Thank you so much for your contribution! The CI failed because there is a lint issue, could you run dart format .?

Copy link

@sagar-pridera sagar-pridera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue fixed

Consider canceling any active work during "dispose" or using the "mounted" getter to determine if the State is still active.

@ricardodalarme
Copy link
Owner

Merged! Thank you so much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants