flame-engine / flame-engine/flame

Multiple GameWidget can share a game; RiverpodAwareGameWidget can't

Open
#3,353 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Dart
Stars
10.8k
Forks
1k
Avg merge
1d 20h
Merged PRs (30d)
21

Description

### 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?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.