onDestroy method

  1. @override
Future<void> onDestroy(
  1. DateTime timestamp,
  2. SendPort? sendPort
)
override

Called when the task is destroyed.

Implementation

@override
Future<void> onDestroy(DateTime timestamp, SendPort? sendPort) async {
  debugPrint("[DEBUG] TaskHandler.onDestroy called at $timestamp");

  // Clean up resources
  await _positionSubscription?.cancel();
  _positionSubscription = null;

  // Send final status message
  sendPort?.send("Foreground location tracking stopped");
}