-
-
Notifications
You must be signed in to change notification settings - Fork 875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
when using FlameBlocProvider components seem to get created twice #2967
Comments
@erickzanardo does this sound familiar? |
It does not. I have taken a look on the source to check if I could find any obvious reason on why this is happening, but I could not spot anything. Would need to do some debugging to understand. |
it seems that the build method is called twice (on the chrome web platform I am testing with) during the loading; @override
Widget build(BuildContext context) {
return GameWidget(
game: SpaceShooterGame(
statsBloc: context.read<GameStatsBloc>(),
inventoryBloc: context.read<InventoryBloc>(),
),
);
} resulting in 2 FlameGames, the first one being removed, but the first still has the children (e.g. PlayerController) with the listeners: void onNewState(GameStatsState state) {
if (state.status == GameStatus.respawn ||
state.status == GameStatus.initial) {
game.statsBloc.add(const PlayerRespawned());
parent?.add(game.player = PlayerComponent());
}
} |
Most likely it is because of ide, try running from console. See here: flutter/flutter#33566 (comment) |
Current bug behavior
I noticed that states are being emitted twice in the flame_bloc game demo here:
https://github.com/flame-engine/flame/blob/main/packages/flame_bloc/example/lib/src/game/game.dart
seems to be the result of these children getting added twice;
flame/packages/flame_bloc/example/lib/src/game/game.dart
Lines 53 to 56 in 5b67b8f
Expected behavior
only add the components to the tree once.
Steps to reproduce
I added some debugging to show the effect:
https://github.com/flame-engine/flame/compare/main...tolland:flame:double-added-bloc?expand=1
This shows that they are being added twice:
same sort of thing on died/respawned
Flutter doctor output
More environment information
Log information
More information
The text was updated successfully, but these errors were encountered: