A command line tool for inspecting and controlling running Flame games.
The flame command inspects and controls a Flame game that is running in debug mode, without
having to open the DevTools. This makes it possible for scripts and AI coding agents to, for
example, see what the game currently looks like.
dart pub global activate flame_cliCreate a new game, like flutter create but from a Flame template and with the Flame packages
set up:
flame create my_game
cd my_gameStart your game with flame run from your project directory. It takes the same arguments as
flutter run, and lets the other commands find the game:
flame run -d macosThen render the whole game to a PNG image:
flame snapshot --output snapshot.pngList the components together with their ids and attributes, and render a single component:
flame tree
flame snapshot --component 220731871Annotate the snapshot with the box, id and type of every visible component, so that what is seen in the image can be matched with the ids, and keep the image within the size limits of AI models:
flame snapshot --annotate --filter 'player|enemy' --max-size 1024Hot reload or restart the game after changing the code, also merging changes to constructors and
onLoad methods into the live components while they keep their state, read its output, open the
Flutter DevTools with the Flame tab for the game, check whether it is running and stop it:
flame reload
flame reload --merge
flame logs
flame devtools
flame status
flame stopPause the game, step it forward a number of frames, inspect and change components, turn on the debug rendering and show or hide overlays:
flame pause
flame step --frames 60
flame inspect 220731871
flame set 220731871 --position 100,200
flame debug on
flame overlay show PauseMenuA running game is tied to its project, so games from different projects never interfere. Several
instances of one project can run at once, for example on two devices: the commands go to the one
started last, and any other one can be addressed with the URI and the port that flame run prints,
through --uri and, for reload, restart, stop and status, --port. The same --uri
option reaches a game that was started in another way, with the Dart VM Service URI that
flutter run prints.
Play the game by sending taps, drags and key presses, to a position or to a component from the tree, wait until something happens in the game, and compare two snapshots:
flame input tap 400,300
flame input tap --component 220731871
flame input drag --from-component 220731871 600,300
flame input key space
flame wait overlay GameOver --timeout 5
flame wait component Enemy --gone
flame diff before.png after.png --output diff.pngPass --json to any command except run to get the result, or the error when it fails, as JSON
on the standard output, for use in scripts and by AI coding agents:
flame snapshot --jsonRun flame --help for all the commands and options, and see the
documentation for more information.