stop method

Future<void> stop()

Implementation

Future<void> stop() async {
  if (_watchedStreams.isNotEmpty) {
    print('Stopping to watch paths...');
    await Future.wait<dynamic>(_watchedStreams.map((s) => s.cancel()));
    _watchedStreams.clear();
  } else {
    print('Was not watching any paths.');
  }

  // to prevent "Unhandled exception: reloadSources: (-32000) Service connection disposed"
  await Future<void>.delayed(const Duration(seconds: 2));

  await _vmService.dispose();
}