gskinner / gskinner/flutter_animate

Add An Equivalent to `AnimatedSwitcher`

Open
#119 8 comments 3 reactions 0 assignees View on GitHub
enhancement Support
Dominant language
Dart
Stars
1.1k
Forks
103
PR merge metrics
No merged PRs in 30d

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:
```dart
@override
Widget build(BuildContext context) {
return AnimatedSwitcher(
duration: kFlipDuration,
transitionBuilder: flipTransitionBuilder,
child: isFlipped ? secondChild : firstChild,
switchInCurve: Curves.easeInBack,
switchOutCurve: Curves.easeInBack.flipped,
);
}

Widget flipTransitionBuilder(
Widget child,
Animation 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.

```dart
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!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.