AnimationController methods were called after calling dispose. #72
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue Description:
When using the AnimationController in Flutter, there is an issue where calling AnimationController.forward() after the controller has been disposed results in the following error:
Solution
Summary of Changes:
To address this issue, I have added a check for the "mounted" property before calling AnimationController.forward(). This ensures that the animation controller is not used after it has been disposed, preventing the error mentioned above.
Code Changes
Context
This change is essential to prevent the usage of the AnimationController after it has been disposed. The mounted property is a reliable way to determine if the widget is still part of the widget tree, and thus, it's safe to call AnimationController.forward().
Testing
I have added relevant tests to ensure that the issue is resolved and that the animation controller is only forwarded when the widget is still mounted.
Reviewer Notes
Please review the changes and confirm that the fix effectively addresses the issue without introducing any regressions. Pay special attention to the added tests and verify that they cover the scenarios related to the problem.