UCameraCapabilities.fromMap constructor

UCameraCapabilities.fromMap(
  1. Map<Object?, Object?> map
)

Implementation

factory UCameraCapabilities.fromMap(Map<Object?, Object?> map) {
  List<T> enums<T extends Enum>(Object? raw, List<T> values) {
    if (raw is! List<Object?>) return <T>[];
    final List<T> out = <T>[];
    for (final String name in raw.whereType<String>()) {
      for (final T candidate in values) {
        if (candidate.name != name) continue;
        out.add(candidate);
        break;
      }
    }
    return out;
  }

  return UCameraCapabilities(
    flash: map["flash"] == true,
    torch: map["torch"] == true,
    zoom: UCameraRange.fromMap(map["zoom"]),
    exposureOffset: UCameraRange.fromMap(map["exposureOffset"]),
    iso: UCameraRange.fromMap(map["iso"]),
    exposureDuration: UCameraRange.fromMap(map["exposureDuration"]),
    focusDistance: UCameraRange.fromMap(map["focusDistance"]),
    temperature: UCameraRange.fromMap(map["temperature"]),
    focusPoint: map["focusPoint"] == true,
    exposurePoint: map["exposurePoint"] == true,
    manualFocus: map["manualFocus"] == true,
    manualExposure: map["manualExposure"] == true,
    whiteBalance: map["whiteBalance"] == true,
    stabilization: enums<UStabilizationMode>(map["stabilization"], UStabilizationMode.values),
    hdr: map["hdr"] == true,
    nightMode: map["nightMode"] == true,
    rawCapture: map["rawCapture"] == true,
    depthCapture: map["depthCapture"] == true,
    videoRecording: map["videoRecording"] == true,
    pauseRecording: map["pauseRecording"] == true,
    audioRecording: map["audioRecording"] == true,
    imageStream: map["imageStream"] == true,
    platformScanning: map["platformScanning"] == true,
    multiCamera: map["multiCamera"] == true,
    pictureInPicture: map["pictureInPicture"] == true,
    lensSwitching: map["lensSwitching"] == true,
    orientationLock: map["orientationLock"] == true,
    snapshot: map["snapshot"] == true,
    videoCodecs: enums<UVideoCodec>(map["videoCodecs"], UVideoCodec.values),
    photoFormats: enums<UPhotoFormat>(map["photoFormats"], UPhotoFormat.values),
    frameFormats: enums<UFrameFormat>(map["frameFormats"], UFrameFormat.values),
    maxPhotoSize: map["maxPhotoSize"] == null ? null : UCameraSize.fromMap(map["maxPhotoSize"]),
    maxVideoSize: map["maxVideoSize"] == null ? null : UCameraSize.fromMap(map["maxVideoSize"]),
    maxFps: ((map["maxFps"] as num?) ?? 30).toDouble(),
  );
}