Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: CameraComponent no longer throws Concurrent modification on stop (…
…#2997) When camera is following a component and trying to follow another target I got an exception: ``` dart:core Iterable.forEach package:flame/src/camera/camera_component.dart 326:25 CameraComponent.stop package:flame/src/camera/camera_component.dart 309:5 CameraComponent.follow test/camera/camera_component_test.dart 69:14 main.<fn>.<fn> package:flame_test/src/test_flame_game.dart 80:21 testWithGame.<fn> Concurrent modification during iteration: _Set len:0. ``` Copying viewfinder children before iterating through it and removing child from parent does the trick, as we are not iterating through the same list as we are removing items from, but rather a copy of it. I tried to use camera from `game` provided in the test but it is AFAIK not mounted and will hence not queue modifications (adds and removes). Hence I create a new camera and mount it.
- Loading branch information