Last active
July 16, 2019 00:19
-
-
Save diegoveloper/f5e172c5e37901fbb99a071d9fc52e0f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AnimatedItem extends StatefulWidget { | |
final String title; | |
const AnimatedItem({Key key, this.title}) : super(key: key); | |
@override | |
_AnimatedItemState createState() => _AnimatedItemState(); | |
} | |
class _AnimatedItemState extends State<AnimatedItem> | |
with SingleTickerProviderStateMixin, AutomaticKeepAliveClientMixin { | |
AnimationController _controller; | |
@override | |
void initState() { | |
super.initState(); | |
_controller = AnimationController( | |
vsync: this, | |
duration: Duration(seconds: 1), | |
); | |
_controller.forward(); | |
} | |
@override | |
void dispose() { | |
super.dispose(); | |
_controller.dispose(); | |
} | |
@override | |
Widget build(BuildContext context) { | |
super.build(context); | |
return SlideTransition( | |
position: Tween<Offset>( | |
begin: Offset(1.0, 0.0), | |
end: Offset(0.0, 0.0), | |
).animate( | |
_controller, | |
), | |
child: ListTile( | |
title: Text(widget.title), | |
), | |
); | |
} | |
@override | |
bool get wantKeepAlive => true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment