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
fix: Hardcode initCurrentGame lifecycle state as resumed #2775
Conversation
@spydon Do I need to add/edit tests for this? |
Yeah, we try to add tests whenever we fix a bug to make sure we don't have regressions later. |
I'm finding this pretty hard to discriminate with tests. Update: I ended up adding some |
Since the method that those methods are using isn't internal or private, I don't see the point in creating them? The correct annotation would be |
We can't use
|
Why not? That was how it was done previously right? |
The existing tests change the lifecycle state after creating the widget, e.g. (tester) async {
await tester.pumpWidget(GameWidget(game: game));
expect(game.paused, isFalse);
WidgetsBinding.instance.handleAppLifecycleStateChanged(
AppLifecycleState.paused,
);
expect(game.paused, isTrue);
}, If you set it to I tried manually instantiating the State object but it threw a bunch of errors because some of its private fields weren't populated. I'm going to try another way to test this which I'll commit in a second |
This new test also correctly succeeds and fails with and without this patch |
Description
When the init game method is called straight after the app has launched, the lifecycle state from
WidgetsBinding.instance.lifecycleState
often returnsdisposed
orinactive
which causes the engine to stay paused even though the app is foregrounded.This PR fixes the lifecycle state as
resumed
when the init method is called.Checklist
docs
and added dartdoc comments with///
.examples
ordocs
.Breaking Change?
Related Issues
Fixes #2771