getCameras static method

Future<List<CameraDescription>> getCameras()

Implementation

static Future<List<CameraDescription>> getCameras() async {
  final cameras = await availableCameras();
  return cameras
    ..sort(
      (a, b) {
        if (a.cameraIDInMobileWeb == b.cameraIDInMobileWeb) {
          return 0;
        }
        if (a.cameraIDInMobileWeb == null) {
          return -1;
        } else if (b.cameraIDInMobileWeb == null) {
          return 1;
        } else if (a.cameraIDInMobileWeb! > b.cameraIDInMobileWeb!) {
          return 1;
        } else {
          return -1;
        }
      },
    );
}