Skip to content

Instantly share code, notes, and snippets.

@fatihkurcenli
Last active July 19, 2021 12:09
Show Gist options
  • Save fatihkurcenli/a1f6ee565df9d4f6e0c39d61b3dfe9af to your computer and use it in GitHub Desktop.
Save fatihkurcenli/a1f6ee565df9d4f6e0c39d61b3dfe9af to your computer and use it in GitHub Desktop.
initState.dart
@override
void initState() {
super.initState();
_animationController = AnimationController(
duration: Duration(seconds: 2),
vsync: this,
);
final animationCurve = CurvedAnimation(
curve: Curves.easeInExpo,
reverseCurve: Curves.easeIn,
parent: _animationController);
_animation = Tween<double>(begin: 5, end: 6).animate(animationCurve)
..addStatusListener((status) {
if (status == AnimationStatus.completed) {
_animationController.reverse();
} else if (status == AnimationStatus.dismissed) {
_animationController.forward();
}
});
animatedStar1 = Tween(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: _animationController, curve: Interval(0.0, 0.5)));
animatedStar1.addListener(() {
setState(() {});
});
animatedStar2 = Tween(begin: 0.0, end: 1.0).animate(CurvedAnimation(
parent: _animationController, curve: Interval(0.5, 1.0)));
animatedStar2.addListener(() {
setState(() {});
});
animatedStar3 = Tween(begin: 1.0, end: 0.0).animate(CurvedAnimation(
parent: _animationController, curve: Interval(0.0, 0.5)));
animatedStar3.addListener(() {
setState(() {});
});
animatedStar4 = Tween(begin: 1.0, end: 0.0).animate(CurvedAnimation(
parent: _animationController, curve: Interval(0.5, 1.0)));
animatedStar4.addListener(() {
setState(() {});
});
for (int i = 0; i < 100; i++) {
listStar.add(WhereStar(
left: Random().nextDouble() * 500,
bottom: Random().nextDouble() * 500,
top: Random().nextDouble() * 500,
extraSize: Random().nextDouble() * 4,
angle: Random().nextDouble(),
typeFade: Random().nextInt(4)));
}
_animationController.forward();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment