stop method

Future<void> stop({
  1. bool clearRoute = true,
})

Implementation

Future<void> stop({bool clearRoute = true}) async {
  if (_shared.closed) return;
  _shared.closed = true;
  try { await _sub?.cancel(); } catch (_) {}
  try { _shared.simTimer?.cancel(); } catch (_) {}
  try { await _headingSub?.cancel(); } catch (_) {}
  if (options.voiceGuidance) {
    try { await _tts?.stop(); } catch (_) {}
  }
  if (defaultTargetPlatform == TargetPlatform.android && options.androidRequestAudioFocus) {
    try { await AudioFocus.abandon(); } catch (_) {}
  }
  if (clearRoute) {
    try { await controller.removePolyline(polylineId); } catch (_) {}
  }
  if (options.showVehicleMarker) {
    try { await controller.removeMarker(options.vehicleMarkerId); } catch (_) {}
  }
  await _stateCtl.close();
  await _instCtl.close();
  await _progressCtl.close();
  await _speedCtl.close();
}