dispose method

  1. @override
Future<void> dispose(
  1. int cameraId
)

Releases the resources of this camera.

Implementation

@override
Future<void> dispose(int cameraId) async {
  try {
    await getCamera(cameraId).dispose();
    await _cameraVideoErrorSubscriptions[cameraId]?.cancel();
    await _cameraVideoAbortSubscriptions[cameraId]?.cancel();
    await _cameraEndedSubscriptions[cameraId]?.cancel();
    await _cameraVideoRecordingErrorSubscriptions[cameraId]?.cancel();

    cameras.remove(cameraId);
    _cameraVideoErrorSubscriptions.remove(cameraId);
    _cameraVideoAbortSubscriptions.remove(cameraId);
    _cameraEndedSubscriptions.remove(cameraId);
  } on html.DomException catch (e) {
    throw PlatformException(code: e.name, message: e.message);
  }
}