Skip to content
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

Multiple GameWidget can share a game; RiverpodAwareGameWidget can't #3353

Open
1 task
TonyDowney opened this issue Oct 24, 2024 · 2 comments
Open
1 task

Comments

@TonyDowney
Copy link

Problem to solve

When using GameWidget, you can make multiple GameWidgets with multiple cameras, sharing the same game:

  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          Expanded(
            child: GameWidget(
              game: this,
              camera: camera1, // First camera view
            ),
          ),
          Expanded(
            child: GameWidget(
              game: this,
              camera: camera2, // Second camera view
            ),
          ),
        ],
      ),
    );
  }

RiverpodAwareGameWidget, which has to be initialized with a GlobalKey, cannot do this. It's a single, unique game per widget.

Proposal

Add the ability to decouple the game from a specific GlobalKey, so it can be shared across an app.

More information

No response

Other

  • Are you interested in working on a PR for this?
@spydon
Copy link
Member

spydon commented Oct 24, 2024

We should indeed support this, but you might not need two GameWidget for your use-case, you can have multiple cameras in one game.

@TonyDowney
Copy link
Author

Related: I tried to get around it with a Hero widget, but because the key is required, it throws errors.

In my opinion, the global key is too tightly coupled, it gets in the way of these edge cases. Not sure uncoupling is viable though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
@spydon @TonyDowney and others