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
Modify AnimatedSwitcher to better allow different in vs. out transitions #19395
Comments
That is a concern but not one that should prevent allowing for the feature. It can be a note that this is a potential issue. In my case I was actually looking to only animate the in, and not have any out animation. I have an item that is Swipeable (with a custom implementation that allows me to swipe in any direction) and then all I do is animate the new item in. |
@dalewking Here is a more polished version of it We will not change the api as this way of changing the animation is not recommended; however, we will document this behavior and add a test to guard against any change to the api. Edit: There is a bug that the initial child is placed in a forward pause direction which it should be reverse pause direction. I will fix this bug Edit: ignore my previous response, the animation is not really useful as the state is inaccurate representation of transition phase, I will try to correct them. I think it is worth doing to simplify the logic as well. Please stay tune |
As I posted in the linked thread there is also some weirdness that the transition builder may or may not be called on the exiting item. If it is a lambda, it fails the equals check and will be called again, if it is a method reference it compares as equal and is not called again. |
We proceeded with the plan to not changing animatedswitcher. The reason being animatedswitcher is not really built for supporting different animations for transition in & out. It might create the risk of having broken animation, and that is against our core values. If you want to have special animation effect different from animatedswitcher, we suggest to build a custom animation widget to achieve the goal. let me know if you have trouble doing so, I am always happy to help. |
As I pointed out in the thread linked in that ticket that works IF you use
a lambda for defining the transition builder. If you move the transition
builder to a function it will not work due to the fact that they will
compare as equal. So it works but by accident.
At least that's what I remember but I have not looked at it in a long time.
…On Sat, May 1, 2021, 6:21 PM Michael McCormick ***@***.***> wrote:
This can be achieved using the following custom transitionBuilder
transitionBuilder: (Widget child, Animation<double> animation) {
if (child.key == ValueKey(index)) {
return SlideTransition(
position: Tween<Offset>(
begin: Offset(1.0, 0),
end: Offset(0.0, 0),
).animate(animation),
child: child,
);
} else {
return SlideTransition(
position: Tween<Offset>(
begin: Offset(-1.0, 0),
end: Offset(0.0, 0),
).animate(animation),
child: child,
);
}
}
Here's a more full example
class MyUI extends StatelessWidget {
}
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#19395 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACUPTUYPC3WLJFWFAIMTQTTLR5HTANCNFSM4FKCFTLQ>
.
|
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
See this discussion I had with myself on flutter_dev: https://groups.google.com/forum/#!topic/flutter-dev/mTKt7qJaqBM
AnimatedSwitcher
is designed to use a single animation for incoming items and the reversed animation for the outgoing items. But that is not always what is desired. For example, I might want to slide new items in from the left and slide the previous item out to the right.It is not clear how to actually achieve that with
AnimatedSwitcher
. As you can see in that thread I spent a day of hacking and figured out how to make it work, but there should be a better, clearly defined way to accomplish this.My thought is another optional
AnimatedSwitcherTransitionBuilder
parameter likeexitTransitionBuilder
that can be passed toAnimatedSwitcher
that is only used on the exiting items. When that parameter is present the Animation should run in the forward direction (i.e. you would not reverse the animation controller for that item).The text was updated successfully, but these errors were encountered: