move method

Particle move()

Move the particle

This method is used to move the particle. It calculates the next position of the particle based on the current position, speed, and angle.

Implementation

Particle move() {
  final next = this + Offset.fromDirection(angle, speed);

  final lifetime = life - 0.01;
  final color = lifetime > .1 ? this.color.withOpacity(lifetime) : this.color;

  return copyWith(
    dx: next.dx,
    dy: next.dy,
    life: lifetime,
    color: color,
    // Random angle
    angle: angle + (Random().nextDouble() - 0.5),
  );
}