How to select the only front-facing camera on Flutter

3,888

Solution 1

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

Solution 2

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);
Share:
3,888
DustinPham
Author by

DustinPham

Updated on December 21, 2022

Comments

  • DustinPham
    DustinPham over 1 year

    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.