flame-engine / flame-engine/flame

addListener or similar to OverlayManager

Open
#3,898 4 comments 0 reactions 1 assignee Claimed by @lea108 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 working with dialogs implemented as overlays, it would be neat to be able to register a callback on the overlays manager to for example play/pause the game when certain overlays are added.

To do that now you have to make wrappers around add/remove/toggle/setActive and make sure you call those and not Game.overlays directly through your app.

### Proposal

Add a addListener() function to OverlayManager, that allow registering a method that will be called whenever the list of active overlays changes.

### More information

On one hand it would be nice to get context in the callback, but I think it is better to follow the overall pattern in Flutter to not provide any context to the listener so it is easier in the future to extend cases it gets triggered and leave it up to the user to detect what changed or just re-compute other states based on overlays state.

### Other

- [x] 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.