initialize method
Implementation
void initialize(Canvas canvas, Size size) {
paintObject = Paint()
..color = dropColors[0]
..style = PaintingStyle.fill;
double effectiveLayer;
for (int i = 0; i < numberOfDrops; i++) {
double x = random.nextDouble() * size.width;
double y = random.nextDouble() * size.height;
int layerNumber =
random.nextInt(numberOfLayers); // 0 is the layer furthest behind
effectiveLayer = layerNumber * distanceBetweenLayers;
dropSize = Size(dropWidth, dropHeight);
dropList.add(
Drop(
drop: Offset(x, y) &
Size(
dropSize.width + (dropSize.width * effectiveLayer),
dropSize.height + (dropSize.height * effectiveLayer),
),
dropSpeed:
dropFallSpeed + (dropFallSpeed * effectiveLayer),
dropLayer: layerNumber,
dropColor: dropColors[random.nextInt(dropColors.length)]),
);
}
}