Don't notify on dispose to avoid exception#38
Don't notify on dispose to avoid exception#38percula wants to merge 16 commits intofunwithflutter:masterfrom percula:master
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
Confettiwidget was disposed:It was being caught by the framework, but started to clog up my logs. Simply avoiding a call to
notifyListenersduringdispose()fixes the issue.