-
Notifications
You must be signed in to change notification settings - Fork 93
Description
One of the things I love the most about flutter_animate is that I can use the extensions to visually separate (in my code) UI elements from the animation effects applied to them. This makes my code MASSIVELY more readable.
The one place where I've struggled is I have a bunch of AnimatedSwitchers and I'm not quite sure how to migrate them. Here's one such example:
@override
Widget build(BuildContext context) {
return AnimatedSwitcher(
duration: kFlipDuration,
transitionBuilder: flipTransitionBuilder,
child: isFlipped ? secondChild : firstChild,
switchInCurve: Curves.easeInBack,
switchOutCurve: Curves.easeInBack.flipped,
);
}
Widget flipTransitionBuilder<T>(
Widget child,
Animation<double> animation,
) { ... }
}I think what I've done above could be achieved via something like toggleEffect + flipEffect, but it feels a bit messy so thus far I've just stuck with AnimatedSwitcher while I migrated all my other animations to flutter_animate.
So, this isn't the highest pri, but here's what I'd like (and I may build a prototype myself):
a SwitchEffect that is as close to AnimatedSwitcher as possible.
return SwitchEffect(
child: isFlipped ? secondChild : firstChild,
).animate().flipEffect( ... ).toggleEffect( ... ); // The effects are only triggered when the child changes.This feels very close to just return ToggleEffect( ... ) but as far as I can tell toggle effect is dependent on the animation, not on an external variable (like the widget child).
I also just may be missing something in flutter_animate that already does this, if I have please let me know as I'd love to migrate all my vanilla fluttter animation logic into flutter_animate!