switchCamera method

Future<void> switchCamera()

Switches between front and back cameras.

Toggles the active camera between the front-facing and back-facing cameras. The camera state is maintained by the platform view.

Example:

// Switch to the other camera
await controller.switchCamera();

Implementation

Future<void> switchCamera() async {
  if (_methodChannel == null) {
    logInfo(
      'YOLOViewController: Warning - Cannot switch camera, view not yet created',
    );
    return;
  }
  try {
    await _methodChannel!.invokeMethod('switchCamera');
    logInfo('YOLOViewController: Switched camera');
  } catch (e) {
    logInfo('YOLOViewController: Error switching camera: $e');
  }
}