Skip to content

Instantly share code, notes, and snippets.

@duytq94
Last active June 25, 2019 03:46
Show Gist options
  • Save duytq94/4a68d41fa4f6251f923f84709aedd446 to your computer and use it in GitHub Desktop.
Save duytq94/4a68d41fa4f6251f923f84709aedd446 to your computer and use it in GitHub Desktop.
class Star {
double left;
double top;
double extraSize;
double angle;
int typeFade;
Star(
{@required this.left,
@required this.top,
@required this.extraSize,
@required this.angle,
@required this.typeFade});
}
// Random star position
for (int i = 0; i < numStars; i++) {
listStar.add(new Star(
left: new Random().nextDouble() * screenSize.width,
top: Random().nextDouble() * screenSize.height,
extraSize: Random().nextDouble() * 2,
angle: Random().nextDouble(),
typeFade: Random().nextInt(4)));
}
// Render these star
Widget buildStar(double left, double top, double extraSize, double angle, int typeFade) {
return new Positioned(
child: new Container(
child: new Transform.rotate(
child: new Opacity(
child: new Icon(
Icons.star,
color: Colors.white,
size: sizeAnimStar.value + extraSize,
),
opacity: (typeFade == 1)
? fadeAnimStar1.value
: (typeFade == 2) ? fadeAnimStar2.value : (typeFade == 3) ? fadeAnimStar3.value : fadeAnimStar4.value,
),
angle: angle,
),
alignment: FractionalOffset.center,
width: 10.0,
height: 10.0,
),
left: left,
top: top,
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment