-
Notifications
You must be signed in to change notification settings - Fork 79
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
Don't notify on dispose to avoid exception #38
base: master
Are you sure you want to change the base?
Conversation
Thanks for the pull request. Do you mind giving an example of when this exception will be thrown. I tried recreating it by replacing the current route while an animation is playing. Dispose is called, and stop is called, but I'm not getting the exception. |
Yep, I replaced the example in the repo with one that throws the exception. It's on this branch: https://github.com/percula/flutter_confetti/tree/exception_example Note that I added Provider. Perhaps that's the reason you didn't see it when you tried to replicate it. |
Ah okay. Because ConfettiController is a ChangeNotifier, and using it with Provider's changenotifier is causing the issue. I like your suggestion with the pull request and I'll merge it in, but maybe in the future this needs to be refactored to not be a ChangeNotifier. A ValueNotifier might be better. Is there any reason you'd want ConfettiController to remain a ChangeNotifier? |
Since ValueNotifier is extended from ChangeNotifier, wouldn't we have the same problem? |
Yes. But I'm thinking of making the The But with this change it would mean you can provide the ConfettiController using a normal Provider (not ChangeNotifierProvider). |
@percula Can you resolve? |
I was encountering the following exception everytime a
Confetti
widget was disposed:It was being caught by the framework, but started to clog up my logs. Simply avoiding a call to
notifyListeners
duringdispose()
fixes the issue.