I have some questions. I'm working over app which uses Flame Engine in Expanded Widget as a part of bigger application. So Flame is used only as graphic representation of buttons and for interaction.
Now, theoretically:
As for code, my counter in app looks like this:
...
Column(
children: [
Text('show 1'),
Text(_firstCounter.toString())
],
),
...
void CountersAndOthers() async {
if(_gameInProgress == true){ return; }
_gameInProgress = true;
_testGame = new TestGame();
_firstCounter = _testGame.counterNumeroUno;
}
And in Flame it's a simple onTap() function that increment int counter:
@override
void onTap() async {
counter++;
print(counter);
jump();
_timer.start();
}
Without using any state management library you can pass in a callback function for you widget to your extended Flame game class and update the state for the widget through that when Flame's onTap
is called.
Here it is the other way around, pass your game class to the navigation buttons and call a function that you make in your flame game that will react to your button presses.
There are multiple more ways of doing this depending on the structure of your app.