-
Notifications
You must be signed in to change notification settings - Fork 86
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
Swap animation not working as expected #116
Comments
This is the expected behaviour, though I agree it can be a bit confusing. Working with complex, multi-target animations is something I'm still trying to think of a better way to manage. Your code is creating two independent animations. The "outside" animation that is fading out the light_mode icon, which ends by swapping its child for the "inside" animation that fades in the dark_mode icon. You are only swapping the This fade out --> fade in use case is one of the trickier things to work with in Animate, and your need to swap content and run in reverse makes it even more complicated. :) I'll think about this, and see if I can come up with an elegant approach either within the current framework, or perhaps informing an update to the library. Even though this is working as intended, I am going to leave this issue open for additional exploration. |
Maybe something like
which would be in my case:
or a similar api with two builders. This may help since the programmer may not know which of the two is the initial widget. In my case the light/dark mode setting is stored in the properties so I need to add a bunch of code to the example in the first post to set the initial icon according to the current setting and the alternate icon respectively to the other option. This may be easier with the approach mentioned above. |
Check out #119 and see if the idea in there would address what you're trying to do. Closing this, but feel free to reopen as appropriate. |
See the following code. When clicking at the icon while the icon shows a sun the animation works as expected (forward). But when clicking while the icon shows the moon the moon immediately vanishes without the specified duration and the sun fades in as expected.
In other words: The fadeIn() for the moon is not working in reverse direction together with swap().
flutter_animate: ^4.2.0+1
[√] Flutter (Channel stable, 3.16.0, on Microsoft Windows [Version 10.0.22621.2428], locale de-AT)
[√] Windows Version (Installed version of Windows is version 10 or higher)
The text was updated successfully, but these errors were encountered: