Search code examples
flutterwidgetgame-engineflame

Can I use a Widget as a actual component in Flutter Flame


Can Flutter Flame render Widget inside game world like other components? (not overlay widget).

(I want to apply forge2d physic to widget and I'm trying to do it with Flame.)


Solution

  • You can not, you can only do it through the overlay system or use a Stack, but the widgets are never "in" the game, but on top of the game. The game can only have Flame Components added directly to it.

    You can still interact with the overlay widgets from the game though, like this for example: https://twitter.com/spydon/status/1417832832693673988

    In that example I simply wrap the ElevatedButton with Positioned and Transform and then I updated those with the values from corresponding BodyComponents.