How to select the only front-facing camera on Flutter

Viewed 4936

I want to select the only front-facing camera when opening Camera View at Flutter. I searched but don't find how to resolve it.

3 Answers

Assuming you are using the this library : Camera

 final cameras = await availableCameras(); //get list of available cameras
 final frontCam = cameras[1]; //get the front camera and do what you want

check lensDirection. You won't be able to tell which facing the first camera is just by index.

(await availableCameras())
...firstWhere((camera) => camera.lensDirection == CameraLensDirection.front);
cameraController = CameraController(
  camera![1], // camera![1] means front camera
  ResolutionPreset.medium,
);
Related