Issue
Can flutter flame (https://flame-engine.org/) be used to create a "flame widget" which can be used within a Flutter app? (i.e. as opposed to having a full flame game, for which you might do flutter widget overlays)
For example say you had a Flutter app, but say within Screen/Page XXX one wanted to have a clock widget (analogue). So in this case in terms of in Flutter how you would create the graphics for an analogue clock could Flame be used for this?
If yes are there any examples of how to do this? (be trying to find some with no success so far, so not sure).
Solution
All Flame games are added to the GameWidget
, and this GameWidget
can be put anywhere inside of your Flutter widget tree.
Do note that if you don’t want your game to be reset when the widget tree is rebuilt, keep a reference to is outside of the GameWidget
.
final game = YourGame();
/// Your flutter widget tree
...
child: GameWidget(game: game);
...
For the specific example you had with an analogue clock it might be possible to use a SpriteAnimationWidget.
Answered By – spydon
Answer Checked By – Mildred Charles (FlutterFixes Admin)