Skip to content

Conversation

@nihil-sine-nikhil
Copy link

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:

flutter: AnimationController.forward() called after AnimationController.dispose()
flutter: AnimationController methods should not be used after calling dispose.

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
image

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.

…roller.forward() to tackle issue where calling AnimationController.forward() was called after the controller has been disposed.
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.

5 participants