cancel method

Future<void> cancel()

Stops the video feed and analyzer

Implementation

Future<void> cancel() async {
  try {
    // Stop the camera stream
    _localStream?.getTracks().forEach((track) {
      if (track.readyState == 'live') {
        track.stop();
      }
    });
  } catch (e) {
    debugPrint('Failed to stop stream: $e');
  }

  video.srcObject = null;
  _localStream = null;
  _frameInterval?.cancel();
  _frameInterval = null;
}