Particle.atPosition constructor
The atPosition property.
Implementation
factory Particle.atPosition(Offset pos, Random random,
{List<Color>? customColors}) {
final colors =
customColors ?? [Colors.red, Colors.orangeAccent, Colors.yellow];
final double angle = random.nextDouble() * 2 * pi;
final double speed = random.nextDouble() * 2.0; // Blast speed
return Particle(
position: pos,
velocity: Offset(cos(angle), sin(angle)) * speed,
life: 1.0,
color: colors[random.nextInt(colors.length)],
size: random.nextDouble() * 3.0 + 2.0, // Size between 2.0 and 5.0
);
}