disposeCurrentGame method

void disposeCurrentGame({
  1. bool callGameOnDispose = false,
})

disposeCurrentGame is called by two flutter events - didUpdateWidget and dispose. When the parameter callGameOnDispose is true, the currentGame's onDispose method will be called; otherwise, it will not.

Implementation

void disposeCurrentGame({bool callGameOnDispose = false}) {
  currentGame.removeGameStateListener(_onGameStateChange);
  currentGame.lifecycleStateChange(AppLifecycleState.paused);
  currentGame.finalizeRemoval();
  if (callGameOnDispose) {
    currentGame.onDispose();
  }
}