Skip to content

Instantly share code, notes, and snippets.

@diegoveloper
Last active July 16, 2019 00:19
Show Gist options
  • Save diegoveloper/f5e172c5e37901fbb99a071d9fc52e0f to your computer and use it in GitHub Desktop.
Save diegoveloper/f5e172c5e37901fbb99a071d9fc52e0f to your computer and use it in GitHub Desktop.
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