updateVisibility method
Implementation
void updateVisibility(Size bounds) {
// Include a margin to account for particles near the edges of the viewport.
const margin = 50.0;
isVisible =
position.dx >= -margin &&
position.dx <= bounds.width + margin &&
position.dy >= -margin &&
position.dy <= bounds.height + margin;
}