【问题标题】:How to select the only front-facing camera on Flutter如何在 Flutter 上选择唯一的前置摄像头
【发布时间】:2020-09-20 18:11:57
【问题描述】:

我想在 Flutter 打开 Camera View 时选择唯一的前置摄像头。 我搜索了但没有找到解决方法。

【问题讨论】:

    标签: android flutter dart mobile camera


    【解决方案1】:

    假设你正在使用这个库:Camera

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

    【讨论】:

      【解决方案2】:

      检查lensDirection。您将无法仅通过索引来判断第一个摄像头的朝向。

      (await availableCameras())
      ...firstWhere((camera) => camera.lensDirection == CameraLensDirection.front);
      

      【讨论】:

        猜你喜欢
        • 2015-10-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-03-06
        • 1970-01-01
        • 2017-06-03
        相关资源
        最近更新 更多