fcmSelectCamera function

CameraDescription? fcmSelectCamera({
  1. required Iterable<CameraDescription> cameras,
  2. String? name,
  3. CameraLensDirection? lensDirection,
})

Implementation

CameraDescription? fcmSelectCamera({
  required Iterable<CameraDescription> cameras,
  String? name,
  CameraLensDirection? lensDirection,
}) {
  if (name != null) {
    final found = cameras.firstWhereOrNull(
      (c) => c.name == name,
    );
    if (found != null) return found;
  }

  if (lensDirection != null) {
    final found = cameras.firstWhereOrNull(
      (c) => c.lensDirection == lensDirection,
    );
    if (found != null) return found;
  }

  return cameras.firstOrNull;
}