stop method

  1. @override
Future<void> stop()
override

Stops the service, once: while the engine disposes, after its plugins detach and before its world goes — services in the reverse of their start order — or when it is removed. It must not touch the world after this is called; the engine's dispose() completes once every stop() has.

Implementation

@override
Future<void> stop() async {
  final game = _game;
  final system = _system;
  if (game != null && system != null && addSystem) {
    // Takes out everything it made while the world still exists.
    game.world.removeSystem(system);
  }
  if (system != null && system.hasWorld) system.physics.dispose();
  _game = null;
  _engine = null;
  _system = null;
  _queries = null;
}