switchCamera method
Switches to next available camera.
Implementation
Future<void> switchCamera() async {
if (_availableCameras.length > 1) {
_selectedCameraIndex =
(_selectedCameraIndex + 1) % _availableCameras.length;
if (_cameraController != null &&
_cameraController!.value.isStreamingImages) {
try {
await _cameraController!.stopImageStream();
} catch (_) {}
}
await _cameraController?.dispose();
_cameraController = null;
_isInitialized = false;
_safeNotifyListeners();
await initialize();
}
}