Flutter Animated IndexedStack
import 'package:flutter/material.dart'; | |
class AnimatedIndexedStack extends StatelessWidget { | |
const AnimatedIndexedStack({ | |
Key key, | |
@required this.index, | |
@required this.children, | |
@required this.duration, | |
}) : super(key: key); | |
final int index; | |
final List<Widget> children; | |
final Duration duration; | |
@override | |
Widget build(BuildContext context) { | |
return IndexedStack( | |
index: index, | |
children: [ | |
for (var i = 0; i < children.length; i++) | |
AnimatedOpacity( | |
opacity: index == i ? 1.0 : 0.0, | |
duration: duration, | |
child: children[i], | |
), | |
], | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment