MRE:
class MyPositionComponent extends PositionComponent {
@override
void onMount() {
super.onMount();
updateChildren();
}
void updateChildren() {
removeAll(children);
for (var i = 0; i < 3; i++) {
add(Component());
}
}
}
final myPositionComponent = MyPositionComponent();
myPositionComponent.updateChildren();
add(myPositionComponent);
Stack trace:
Performing hot restart...
Syncing files to device iPhone 14 Pro Max...
Restarted application in 575ms.
flutter: βββ‘ EXCEPTION CAUGHT BY WIDGETS LIBRARY ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
flutter: The following ConcurrentModificationError was thrown building FutureBuilder<void>(dirty, state:
flutter: _FutureBuilderState<void>#d9233):
flutter: Concurrent modification during iteration: _Set len:2.
flutter:
flutter: The relevant error-causing widget was:
flutter: FutureBuilder<void>
flutter: FutureBuilder:file:///Users/denisgladky/.pub-cache/hosted/pub.dev/flame-1.12.0/lib/src/game/game_widget/game_widget.dart:389:30
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 _CompactIterator.moveNext (dart:collection-patch/compact_hash.dart:710:7)
flutter: #1 ExpandIterator.moveNext (dart:_internal/iterable.dart:477:32)
flutter: #2 Iterable.forEach (dart:core/iterable.dart:347:23)
flutter: #3 Component.removeAll (package:flame/src/components/core/component.dart:628:64)
flutter: #4 MyPositionComponent.updateChildren (package:voltlab/presentation/screens/dev_screens/dev_conductor/dev_conductor_flame.dart:225:5)
flutter: #5 MyPositionComponent.onMount (package:voltlab/presentation/screens/dev_screens/dev_conductor/dev_conductor_flame.dart:221:5)
flutter: #6 Component._mount (package:flame/src/components/core/component.dart:891:5)
flutter: #7 Component.handleLifecycleEventAdd (package:flame/src/components/core/component.dart:807:7)
flutter: #8 ComponentTreeRoot.processLifecycleEvents (package:flame/src/components/core/component_tree_root.dart:92:28)
flutter: #9 FlameGame.updateTree (package:flame/src/game/flame_game.dart:137:5)
flutter: #10 FlameGame.update (package:flame/src/game/flame_game.dart:131:7)
flutter: #11 GameWidgetState.loaderFuture.<anonymous closure> (package:flame/src/game/game_widget/game_widget.dart:200:16)
flutter: <asynchronous suspension>
flutter: #12 _FutureBuilderState._subscribe.<anonymous closure> (package:flutter/src/widgets/async.dart:624:33)
flutter: <asynchronous suspension>
flutter:
flutter: ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
flutter: βββ‘ EXCEPTION CAUGHT BY WIDGETS LIBRARY ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
flutter: The following ConcurrentModificationError was thrown building FutureBuilder<void>(dirty, state:
flutter: _FutureBuilderState<void>#d9233):
flutter: Concurrent modification during iteration: _Set len:2.
flutter:
flutter: The relevant error-causing widget was:
flutter: GameWidget<DevConductorFlameGame>
flutter: GameWidget:file:///Users/denisgladky/IdeaProject/voltlab/lib/presentation/screens/base_screens/base_flutter_screens/base_electric_circuit_screen.dart:99:12
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0 _CompactIterator.moveNext (dart:collection-patch/compact_hash.dart:710:7)
flutter: #1 ExpandIterator.moveNext (dart:_internal/iterable.dart:477:32)
flutter: #2 Iterable.forEach (dart:core/iterable.dart:347:23)
flutter: #3 Component.removeAll (package:flame/src/components/core/component.dart:628:64)
flutter: #4 MyPositionComponent.updateChildren (package:voltlab/presentation/screens/dev_screens/dev_conductor/dev_conductor_flame.dart:225:5)
flutter: #5 MyPositionComponent.onMount (package:voltlab/presentation/screens/dev_screens/dev_conductor/dev_conductor_flame.dart:221:5)
flutter: #6 Component._mount (package:flame/src/components/core/component.dart:891:5)
flutter: #7 Component.handleLifecycleEventAdd (package:flame/src/components/core/component.dart:807:7)
flutter: #8 ComponentTreeRoot.processLifecycleEvents (package:flame/src/components/core/component_tree_root.dart:92:28)
flutter: #9 FlameGame.updateTree (package:flame/src/game/flame_game.dart:137:5)
flutter: #10 FlameGame.update (package:flame/src/game/flame_game.dart:131:7)
flutter: #11 GameWidgetState.loaderFuture.<anonymous closure> (package:flame/src/game/game_widget/game_widget.dart:200:16)
flutter: <asynchronous suspension>
flutter: #12 _FutureBuilderState._subscribe.<anonymous closure> (package:flutter/src/widgets/async.dart:624:33)
flutter: <asynchronous suspension>
flutter:
flutter: ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
flutter: Another exception was thrown: Concurrent modification during iteration: _Set len:2.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too