From 9cfa3f001ec89f4f07d52eef97e95f426dbe5351 Mon Sep 17 00:00:00 2001 From: Mairramer Date: Fri, 1 May 2026 12:18:08 -0300 Subject: [PATCH 1/4] feat: add rgba8888 format support to image format group --- packages/camera/camera/example/pubspec.yaml | 4 + .../camera_android_camerax/CHANGELOG.md | 4 + .../example/pubspec.yaml | 4 + .../lib/src/android_camera_camerax.dart | 14 + .../camera_android_camerax/pubspec.yaml | 6 +- .../test/android_camera_camerax_test.dart | 2 + .../camera/camera_avfoundation/CHANGELOG.md | 4 + .../RunnerTests/CameraPropertiesTests.swift | 3 + .../CameraProperties.swift | 2 + .../camera_avfoundation/Messages.swift | 433 +++--- .../lib/src/avfoundation_camera.dart | 2 + .../lib/src/messages.g.dart | 1215 +++++++---------- .../lib/src/type_conversion.dart | 3 + .../camera_avfoundation/pigeons/messages.dart | 2 +- .../camera/camera_avfoundation/pubspec.yaml | 6 +- .../camera_platform_interface/CHANGELOG.md | 4 + .../lib/src/types/image_format_group.dart | 11 + .../camera_platform_interface/pubspec.yaml | 2 +- .../test/types/image_group_test.dart | 1 + 19 files changed, 796 insertions(+), 926 deletions(-) diff --git a/packages/camera/camera/example/pubspec.yaml b/packages/camera/camera/example/pubspec.yaml index b5d9dff6e913..822ca935a164 100644 --- a/packages/camera/camera/example/pubspec.yaml +++ b/packages/camera/camera/example/pubspec.yaml @@ -31,3 +31,7 @@ dev_dependencies: flutter: uses-material-design: true +# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. +# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins +dependency_overrides: + camera_platform_interface: {path: ../../../../packages/camera/camera_platform_interface} diff --git a/packages/camera/camera_android_camerax/CHANGELOG.md b/packages/camera/camera_android_camerax/CHANGELOG.md index 191d67e7a1c8..7a0566d06148 100644 --- a/packages/camera/camera_android_camerax/CHANGELOG.md +++ b/packages/camera/camera_android_camerax/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.7.3 + +* Adds support for `ImageFormatGroup.rgba8888` image format. + ## 0.7.2 * Bumps camerax_version from 1.5.3 to 1.6.0. diff --git a/packages/camera/camera_android_camerax/example/pubspec.yaml b/packages/camera/camera_android_camerax/example/pubspec.yaml index 81a4e079b2ae..2f59cb505d84 100644 --- a/packages/camera/camera_android_camerax/example/pubspec.yaml +++ b/packages/camera/camera_android_camerax/example/pubspec.yaml @@ -28,4 +28,8 @@ dev_dependencies: flutter: uses-material-design: true +# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. +# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins +dependency_overrides: + camera_platform_interface: {path: ../../../../packages/camera/camera_platform_interface} diff --git a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart index e52e4bd09cf1..22f2cdc9242e 100644 --- a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart +++ b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart @@ -184,6 +184,11 @@ class AndroidCameraCameraX extends CameraPlatform { /// See https://developer.android.com/reference/android/graphics/ImageFormat#JPEG. static const int imageProxyFormatJpeg = 256; + /// Constant representing the FLEX_RGBA_8888 image format used by ImageProxy. + /// + /// See https://developer.android.com/reference/android/graphics/ImageFormat#FLEX_RGBA_8888. + static const int imageProxyFormatRgba8888 = 42; + /// Constant representing the YUV 420 image format used for configuring ImageAnalysis. /// /// See https://developer.android.com/reference/androidx/camera/core/ImageAnalysis#OUTPUT_IMAGE_FORMAT_YUV_420_888() @@ -194,6 +199,11 @@ class AndroidCameraCameraX extends CameraPlatform { /// See https://developer.android.com/reference/androidx/camera/core/ImageAnalysis#OUTPUT_IMAGE_FORMAT_NV21(). static const int imageAnalysisOutputImageFormatNv21 = 3; + /// Constant representing the RGBA 8888 image format used for configuring ImageAnalysis. + /// + /// See https://developer.android.com/reference/androidx/camera/core/ImageAnalysis#OUTPUT_IMAGE_FORMAT_RGBA_8888() + static const int imageAnalysisOutputImageFormatRgba8888 = 2; + /// Error code indicating a [ZoomState] was requested, but one has not been /// set for the camera in use. static const String zoomStateNotSetErrorCode = 'zoomStateNotSet'; @@ -1447,6 +1457,8 @@ class AndroidCameraCameraX extends CameraPlatform { return imageAnalysisOutputImageFormatYuv420_888; case ImageFormatGroup.nv21: return imageAnalysisOutputImageFormatNv21; + case ImageFormatGroup.rgba8888: + return imageAnalysisOutputImageFormatRgba8888; } return null; @@ -1463,6 +1475,8 @@ class AndroidCameraCameraX extends CameraPlatform { return ImageFormatGroup.nv21; case imageProxyFormatJpeg: // android.graphics.ImageFormat.JPEG return ImageFormatGroup.jpeg; + case imageProxyFormatRgba8888: // android.graphics.ImageFormat.FLEX_RGBA_8888 + return ImageFormatGroup.rgba8888; } return ImageFormatGroup.unknown; diff --git a/packages/camera/camera_android_camerax/pubspec.yaml b/packages/camera/camera_android_camerax/pubspec.yaml index 6e928e2518aa..2afd3fd33519 100644 --- a/packages/camera/camera_android_camerax/pubspec.yaml +++ b/packages/camera/camera_android_camerax/pubspec.yaml @@ -2,7 +2,7 @@ name: camera_android_camerax description: Android implementation of the camera plugin using the CameraX library. repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_android_camerax issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22 -version: 0.7.2 +version: 0.7.3 environment: sdk: ^3.9.0 @@ -35,3 +35,7 @@ dev_dependencies: topics: - camera +# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. +# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins +dependency_overrides: + camera_platform_interface: {path: ../camera_platform_interface} diff --git a/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart b/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart index 71ed3d58ccde..f3f095b0c6c7 100644 --- a/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart +++ b/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart @@ -2099,6 +2099,8 @@ void main() { AndroidCameraCameraX.imageAnalysisOutputImageFormatYuv420_888, ImageFormatGroup.nv21 => AndroidCameraCameraX.imageAnalysisOutputImageFormatNv21, + ImageFormatGroup.rgba8888 => + AndroidCameraCameraX.imageAnalysisOutputImageFormatRgba8888, _ => null, }; // Tell plugin to create mock/detached objects for testing createCamera diff --git a/packages/camera/camera_avfoundation/CHANGELOG.md b/packages/camera/camera_avfoundation/CHANGELOG.md index ca97b101df8b..b10ce0bc3409 100644 --- a/packages/camera/camera_avfoundation/CHANGELOG.md +++ b/packages/camera/camera_avfoundation/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.10.2 + +* Adds support for `ImageFormatGroup.rgba8888` image format. + ## 0.10.1 * Fixes fatal crash on iPhone 17 when using `ResolutionPreset.max`. diff --git a/packages/camera/camera_avfoundation/example/ios/RunnerTests/CameraPropertiesTests.swift b/packages/camera/camera_avfoundation/example/ios/RunnerTests/CameraPropertiesTests.swift index bac0ce6ed19e..3baae61ab0f9 100644 --- a/packages/camera/camera_avfoundation/example/ios/RunnerTests/CameraPropertiesTests.swift +++ b/packages/camera/camera_avfoundation/example/ios/RunnerTests/CameraPropertiesTests.swift @@ -32,6 +32,9 @@ final class CameraPropertiesTests: XCTestCase { XCTAssertEqual( kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange, getPixelFormat(for: .yuv420)) + XCTAssertEqual( + kCVPixelFormatType_32RGBA, + getPixelFormat(for: .rgba8888)) } // MARK: - Device Orientation Tests diff --git a/packages/camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/CameraProperties.swift b/packages/camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/CameraProperties.swift index a7dfd4551048..d428c915429a 100644 --- a/packages/camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/CameraProperties.swift +++ b/packages/camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/CameraProperties.swift @@ -71,6 +71,8 @@ func getPixelFormat(for imageFormat: PlatformImageFormatGroup) -> OSType { return kCVPixelFormatType_32BGRA case .yuv420: return kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange + case .rgba8888: + return kCVPixelFormatType_32RGBA @unknown default: assertionFailure("Unknown image format") return kCVPixelFormatType_32BGRA diff --git a/packages/camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/Messages.swift b/packages/camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/Messages.swift index 47e6abbbe750..47b40048e92b 100644 --- a/packages/camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/Messages.swift +++ b/packages/camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/Messages.swift @@ -1,7 +1,7 @@ // Copyright 2013 The Flutter Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v26.1.5), do not edit directly. +// Autogenerated from Pigeon (v26.3.4), do not edit directly. // See also: https://pub.dev/packages/pigeon import Foundation @@ -53,15 +53,13 @@ private func wrapError(_ error: Any) -> [Any?] { } return [ "\(error)", - "\(type(of: error))", + "\(Swift.type(of: error))", "Stacktrace: \(Thread.callStackSymbols)", ] } private func createConnectionError(withChannelName channelName: String) -> PigeonError { - return PigeonError( - code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.", - details: "") + return PigeonError(code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.", details: "") } private func isNullish(_ value: Any?) -> Bool { @@ -73,6 +71,19 @@ private func nilOrValue(_ value: Any?) -> T? { return value as! T? } +private func doubleEqualsMessages(_ lhs: Double, _ rhs: Double) -> Bool { + return (lhs.isNaN && rhs.isNaN) || lhs == rhs +} + +private func doubleHashMessages(_ value: Double, _ hasher: inout Hasher) { + if value.isNaN { + hasher.combine(0x7FF8000000000000) + } else { + // Normalize -0.0 to 0.0 + hasher.combine(value == 0 ? 0 : value) + } +} + func deepEqualsMessages(_ lhs: Any?, _ rhs: Any?) -> Bool { let cleanLhs = nilOrValue(lhs) as Any? let cleanRhs = nilOrValue(rhs) as Any? @@ -83,58 +94,93 @@ func deepEqualsMessages(_ lhs: Any?, _ rhs: Any?) -> Bool { case (nil, _), (_, nil): return false - case is (Void, Void): + case (let lhs as AnyObject, let rhs as AnyObject) where lhs === rhs: return true - case let (cleanLhsHashable, cleanRhsHashable) as (AnyHashable, AnyHashable): - return cleanLhsHashable == cleanRhsHashable + case is (Void, Void): + return true - case let (cleanLhsArray, cleanRhsArray) as ([Any?], [Any?]): - guard cleanLhsArray.count == cleanRhsArray.count else { return false } - for (index, element) in cleanLhsArray.enumerated() { - if !deepEqualsMessages(element, cleanRhsArray[index]) { + case (let lhsArray, let rhsArray) as ([Any?], [Any?]): + guard lhsArray.count == rhsArray.count else { return false } + for (index, element) in lhsArray.enumerated() { + if !deepEqualsMessages(element, rhsArray[index]) { return false } } return true - case let (cleanLhsDictionary, cleanRhsDictionary) as ([AnyHashable: Any?], [AnyHashable: Any?]): - guard cleanLhsDictionary.count == cleanRhsDictionary.count else { return false } - for (key, cleanLhsValue) in cleanLhsDictionary { - guard cleanRhsDictionary.index(forKey: key) != nil else { return false } - if !deepEqualsMessages(cleanLhsValue, cleanRhsDictionary[key]!) { + case (let lhsArray, let rhsArray) as ([Double], [Double]): + guard lhsArray.count == rhsArray.count else { return false } + for (index, element) in lhsArray.enumerated() { + if !doubleEqualsMessages(element, rhsArray[index]) { return false } } return true + case (let lhsDictionary, let rhsDictionary) as ([AnyHashable: Any?], [AnyHashable: Any?]): + guard lhsDictionary.count == rhsDictionary.count else { return false } + for (lhsKey, lhsValue) in lhsDictionary { + var found = false + for (rhsKey, rhsValue) in rhsDictionary { + if deepEqualsMessages(lhsKey, rhsKey) { + if deepEqualsMessages(lhsValue, rhsValue) { + found = true + break + } else { + return false + } + } + } + if !found { return false } + } + return true + + case (let lhs as Double, let rhs as Double): + return doubleEqualsMessages(lhs, rhs) + + case (let lhsHashable, let rhsHashable) as (AnyHashable, AnyHashable): + return lhsHashable == rhsHashable + default: - // Any other type shouldn't be able to be used with pigeon. File an issue if you find this to be untrue. return false } } func deepHashMessages(value: Any?, hasher: inout Hasher) { - if let valueList = value as? [AnyHashable] { - for item in valueList { deepHashMessages(value: item, hasher: &hasher) } - return - } - - if let valueDict = value as? [AnyHashable: AnyHashable] { - for key in valueDict.keys { - hasher.combine(key) - deepHashMessages(value: valueDict[key]!, hasher: &hasher) + let cleanValue = nilOrValue(value) as Any? + if let cleanValue = cleanValue { + if let doubleValue = cleanValue as? Double { + doubleHashMessages(doubleValue, &hasher) + } else if let valueList = cleanValue as? [Any?] { + for item in valueList { + deepHashMessages(value: item, hasher: &hasher) + } + } else if let valueList = cleanValue as? [Double] { + for item in valueList { + doubleHashMessages(item, &hasher) + } + } else if let valueDict = cleanValue as? [AnyHashable: Any?] { + var result = 0 + for (key, value) in valueDict { + var entryKeyHasher = Hasher() + deepHashMessages(value: key, hasher: &entryKeyHasher) + var entryValueHasher = Hasher() + deepHashMessages(value: value, hasher: &entryValueHasher) + result = result &+ ((entryKeyHasher.finalize() &* 31) ^ entryValueHasher.finalize()) + } + hasher.combine(result) + } else if let hashableValue = cleanValue as? AnyHashable { + hasher.combine(hashableValue) + } else { + hasher.combine(String(describing: cleanValue)) } - return + } else { + hasher.combine(0) } - - if let hashableValue = value as? AnyHashable { - hasher.combine(hashableValue.hashValue) - } - - return hasher.combine(String(describing: value)) } + enum PlatformCameraLensDirection: Int { /// Front facing camera (a user looking at the screen is seen by the camera). case front = 0 @@ -188,6 +234,7 @@ enum PlatformImageFileFormat: Int { enum PlatformImageFormatGroup: Int { case bgra8888 = 0 case yuv420 = 1 + case rgba8888 = 2 } enum PlatformResolutionPreset: Int { @@ -215,6 +262,7 @@ struct PlatformCameraDescription: Hashable { /// The type of the camera lens. var lensType: PlatformCameraLensType + // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> PlatformCameraDescription? { let name = pigeonVar_list[0] as! String @@ -235,10 +283,17 @@ struct PlatformCameraDescription: Hashable { ] } static func == (lhs: PlatformCameraDescription, rhs: PlatformCameraDescription) -> Bool { - return deepEqualsMessages(lhs.toList(), rhs.toList()) + if Swift.type(of: lhs) != Swift.type(of: rhs) { + return false + } + return deepEqualsMessages(lhs.name, rhs.name) && deepEqualsMessages(lhs.lensDirection, rhs.lensDirection) && deepEqualsMessages(lhs.lensType, rhs.lensType) } + func hash(into hasher: inout Hasher) { - deepHashMessages(value: toList(), hasher: &hasher) + hasher.combine("PlatformCameraDescription") + deepHashMessages(value: name, hasher: &hasher) + deepHashMessages(value: lensDirection, hasher: &hasher) + deepHashMessages(value: lensType, hasher: &hasher) } } @@ -255,6 +310,7 @@ struct PlatformCameraState: Hashable { /// Whether setting focus points is supported. var focusPointSupported: Bool + // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> PlatformCameraState? { let previewSize = pigeonVar_list[0] as! PlatformSize @@ -281,10 +337,19 @@ struct PlatformCameraState: Hashable { ] } static func == (lhs: PlatformCameraState, rhs: PlatformCameraState) -> Bool { - return deepEqualsMessages(lhs.toList(), rhs.toList()) + if Swift.type(of: lhs) != Swift.type(of: rhs) { + return false + } + return deepEqualsMessages(lhs.previewSize, rhs.previewSize) && deepEqualsMessages(lhs.exposureMode, rhs.exposureMode) && deepEqualsMessages(lhs.focusMode, rhs.focusMode) && deepEqualsMessages(lhs.exposurePointSupported, rhs.exposurePointSupported) && deepEqualsMessages(lhs.focusPointSupported, rhs.focusPointSupported) } + func hash(into hasher: inout Hasher) { - deepHashMessages(value: toList(), hasher: &hasher) + hasher.combine("PlatformCameraState") + deepHashMessages(value: previewSize, hasher: &hasher) + deepHashMessages(value: exposureMode, hasher: &hasher) + deepHashMessages(value: focusMode, hasher: &hasher) + deepHashMessages(value: exposurePointSupported, hasher: &hasher) + deepHashMessages(value: focusPointSupported, hasher: &hasher) } } @@ -299,6 +364,7 @@ struct PlatformCameraImageData: Hashable { var sensorExposureTimeNanoseconds: Int64 var sensorSensitivity: Double + // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> PlatformCameraImageData? { let formatCode = pigeonVar_list[0] as! Int64 @@ -331,10 +397,21 @@ struct PlatformCameraImageData: Hashable { ] } static func == (lhs: PlatformCameraImageData, rhs: PlatformCameraImageData) -> Bool { - return deepEqualsMessages(lhs.toList(), rhs.toList()) + if Swift.type(of: lhs) != Swift.type(of: rhs) { + return false + } + return deepEqualsMessages(lhs.formatCode, rhs.formatCode) && deepEqualsMessages(lhs.width, rhs.width) && deepEqualsMessages(lhs.height, rhs.height) && deepEqualsMessages(lhs.planes, rhs.planes) && deepEqualsMessages(lhs.lensAperture, rhs.lensAperture) && deepEqualsMessages(lhs.sensorExposureTimeNanoseconds, rhs.sensorExposureTimeNanoseconds) && deepEqualsMessages(lhs.sensorSensitivity, rhs.sensorSensitivity) } + func hash(into hasher: inout Hasher) { - deepHashMessages(value: toList(), hasher: &hasher) + hasher.combine("PlatformCameraImageData") + deepHashMessages(value: formatCode, hasher: &hasher) + deepHashMessages(value: width, hasher: &hasher) + deepHashMessages(value: height, hasher: &hasher) + deepHashMessages(value: planes, hasher: &hasher) + deepHashMessages(value: lensAperture, hasher: &hasher) + deepHashMessages(value: sensorExposureTimeNanoseconds, hasher: &hasher) + deepHashMessages(value: sensorSensitivity, hasher: &hasher) } } @@ -345,6 +422,7 @@ struct PlatformCameraImagePlane: Hashable { var width: Int64 var height: Int64 + // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> PlatformCameraImagePlane? { let bytes = pigeonVar_list[0] as! FlutterStandardTypedData @@ -368,10 +446,18 @@ struct PlatformCameraImagePlane: Hashable { ] } static func == (lhs: PlatformCameraImagePlane, rhs: PlatformCameraImagePlane) -> Bool { - return deepEqualsMessages(lhs.toList(), rhs.toList()) + if Swift.type(of: lhs) != Swift.type(of: rhs) { + return false + } + return deepEqualsMessages(lhs.bytes, rhs.bytes) && deepEqualsMessages(lhs.bytesPerRow, rhs.bytesPerRow) && deepEqualsMessages(lhs.width, rhs.width) && deepEqualsMessages(lhs.height, rhs.height) } + func hash(into hasher: inout Hasher) { - deepHashMessages(value: toList(), hasher: &hasher) + hasher.combine("PlatformCameraImagePlane") + deepHashMessages(value: bytes, hasher: &hasher) + deepHashMessages(value: bytesPerRow, hasher: &hasher) + deepHashMessages(value: width, hasher: &hasher) + deepHashMessages(value: height, hasher: &hasher) } } @@ -383,6 +469,7 @@ struct PlatformMediaSettings: Hashable { var audioBitrate: Int64? = nil var enableAudio: Bool + // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> PlatformMediaSettings? { let resolutionPreset = pigeonVar_list[0] as! PlatformResolutionPreset @@ -409,10 +496,19 @@ struct PlatformMediaSettings: Hashable { ] } static func == (lhs: PlatformMediaSettings, rhs: PlatformMediaSettings) -> Bool { - return deepEqualsMessages(lhs.toList(), rhs.toList()) + if Swift.type(of: lhs) != Swift.type(of: rhs) { + return false + } + return deepEqualsMessages(lhs.resolutionPreset, rhs.resolutionPreset) && deepEqualsMessages(lhs.framesPerSecond, rhs.framesPerSecond) && deepEqualsMessages(lhs.videoBitrate, rhs.videoBitrate) && deepEqualsMessages(lhs.audioBitrate, rhs.audioBitrate) && deepEqualsMessages(lhs.enableAudio, rhs.enableAudio) } + func hash(into hasher: inout Hasher) { - deepHashMessages(value: toList(), hasher: &hasher) + hasher.combine("PlatformMediaSettings") + deepHashMessages(value: resolutionPreset, hasher: &hasher) + deepHashMessages(value: framesPerSecond, hasher: &hasher) + deepHashMessages(value: videoBitrate, hasher: &hasher) + deepHashMessages(value: audioBitrate, hasher: &hasher) + deepHashMessages(value: enableAudio, hasher: &hasher) } } @@ -421,6 +517,7 @@ struct PlatformPoint: Hashable { var x: Double var y: Double + // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> PlatformPoint? { let x = pigeonVar_list[0] as! Double @@ -438,10 +535,16 @@ struct PlatformPoint: Hashable { ] } static func == (lhs: PlatformPoint, rhs: PlatformPoint) -> Bool { - return deepEqualsMessages(lhs.toList(), rhs.toList()) + if Swift.type(of: lhs) != Swift.type(of: rhs) { + return false + } + return deepEqualsMessages(lhs.x, rhs.x) && deepEqualsMessages(lhs.y, rhs.y) } + func hash(into hasher: inout Hasher) { - deepHashMessages(value: toList(), hasher: &hasher) + hasher.combine("PlatformPoint") + deepHashMessages(value: x, hasher: &hasher) + deepHashMessages(value: y, hasher: &hasher) } } @@ -450,6 +553,7 @@ struct PlatformSize: Hashable { var width: Double var height: Double + // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> PlatformSize? { let width = pigeonVar_list[0] as! Double @@ -467,10 +571,16 @@ struct PlatformSize: Hashable { ] } static func == (lhs: PlatformSize, rhs: PlatformSize) -> Bool { - return deepEqualsMessages(lhs.toList(), rhs.toList()) + if Swift.type(of: lhs) != Swift.type(of: rhs) { + return false + } + return deepEqualsMessages(lhs.width, rhs.width) && deepEqualsMessages(lhs.height, rhs.height) } + func hash(into hasher: inout Hasher) { - deepHashMessages(value: toList(), hasher: &hasher) + hasher.combine("PlatformSize") + deepHashMessages(value: width, hasher: &hasher) + deepHashMessages(value: height, hasher: &hasher) } } @@ -630,22 +740,17 @@ class MessagesPigeonCodec: FlutterStandardMessageCodec, @unchecked Sendable { static let shared = MessagesPigeonCodec(readerWriter: MessagesPigeonCodecReaderWriter()) } -var messagesPigeonMethodCodec = FlutterStandardMethodCodec( - readerWriter: MessagesPigeonCodecReaderWriter()) +var messagesPigeonMethodCodec = FlutterStandardMethodCodec(readerWriter: MessagesPigeonCodecReaderWriter()); + /// Generated protocol from Pigeon that represents a handler of messages from Flutter. protocol CameraApi { /// Returns the list of available cameras. - func getAvailableCameras( - completion: @escaping (Result<[PlatformCameraDescription], Error>) -> Void) + func getAvailableCameras(completion: @escaping (Result<[PlatformCameraDescription], Error>) -> Void) /// Create a new camera with the given settings, and returns its ID. - func create( - cameraName: String, settings: PlatformMediaSettings, - completion: @escaping (Result) -> Void) + func create(cameraName: String, settings: PlatformMediaSettings, completion: @escaping (Result) -> Void) /// Initializes the camera with the given ID. - func initialize( - cameraId: Int64, imageFormat: PlatformImageFormatGroup, - completion: @escaping (Result) -> Void) + func initialize(cameraId: Int64, imageFormat: PlatformImageFormatGroup, completion: @escaping (Result) -> Void) /// Begins streaming frames from the camera. func startImageStream(completion: @escaping (Result) -> Void) /// Stops streaming frames from the camera. @@ -659,8 +764,7 @@ protocol CameraApi { /// and any associated resources can be cleaned up. func dispose(cameraId: Int64, completion: @escaping (Result) -> Void) /// Locks the camera capture to the current device orientation. - func lockCaptureOrientation( - orientation: PlatformDeviceOrientation, completion: @escaping (Result) -> Void) + func lockCaptureOrientation(orientation: PlatformDeviceOrientation, completion: @escaping (Result) -> Void) /// Unlocks camera capture orientation, allowing it to automatically adapt to /// device orientation. func unlockCaptureOrientation(completion: @escaping (Result) -> Void) @@ -681,8 +785,7 @@ protocol CameraApi { /// Switches the camera to the given flash mode. func setFlashMode(mode: PlatformFlashMode, completion: @escaping (Result) -> Void) /// Switches the camera to the given exposure mode. - func setExposureMode( - mode: PlatformExposureMode, completion: @escaping (Result) -> Void) + func setExposureMode(mode: PlatformExposureMode, completion: @escaping (Result) -> Void) /// Anchors auto-exposure to the given point in (0,1) coordinate space. /// /// A null value resets to the default exposure point. @@ -706,11 +809,9 @@ protocol CameraApi { /// Sets the zoom factor. func setZoomLevel(zoom: Double, completion: @escaping (Result) -> Void) /// Sets the video stabilization mode. - func setVideoStabilizationMode( - mode: PlatformVideoStabilizationMode, completion: @escaping (Result) -> Void) + func setVideoStabilizationMode(mode: PlatformVideoStabilizationMode, completion: @escaping (Result) -> Void) /// Gets if the given video stabilization mode is supported. - func isVideoStabilizationModeSupported( - mode: PlatformVideoStabilizationMode, completion: @escaping (Result) -> Void) + func isVideoStabilizationModeSupported(mode: PlatformVideoStabilizationMode, completion: @escaping (Result) -> Void) /// Pauses streaming of preview frames. func pausePreview(completion: @escaping (Result) -> Void) /// Resumes a previously paused preview stream. @@ -718,25 +819,19 @@ protocol CameraApi { /// Changes the camera used while recording video. /// /// This should only be called while video recording is active. - func updateDescriptionWhileRecording( - cameraName: String, completion: @escaping (Result) -> Void) + func updateDescriptionWhileRecording(cameraName: String, completion: @escaping (Result) -> Void) /// Sets the file format used for taking pictures. - func setImageFileFormat( - format: PlatformImageFileFormat, completion: @escaping (Result) -> Void) + func setImageFileFormat(format: PlatformImageFileFormat, completion: @escaping (Result) -> Void) } /// Generated setup class from Pigeon to handle messages through the `binaryMessenger`. class CameraApiSetup { static var codec: FlutterStandardMessageCodec { MessagesPigeonCodec.shared } /// Sets up an instance of `CameraApi` to handle messages through the `binaryMessenger`. - static func setUp( - binaryMessenger: FlutterBinaryMessenger, api: CameraApi?, messageChannelSuffix: String = "" - ) { + static func setUp(binaryMessenger: FlutterBinaryMessenger, api: CameraApi?, messageChannelSuffix: String = "") { let channelSuffix = messageChannelSuffix.count > 0 ? ".\(messageChannelSuffix)" : "" /// Returns the list of available cameras. - let getAvailableCamerasChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.getAvailableCameras\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let getAvailableCamerasChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.getAvailableCameras\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { getAvailableCamerasChannel.setMessageHandler { _, reply in api.getAvailableCameras { result in @@ -752,9 +847,7 @@ class CameraApiSetup { getAvailableCamerasChannel.setMessageHandler(nil) } /// Create a new camera with the given settings, and returns its ID. - let createChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.create\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let createChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.create\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { createChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -773,9 +866,7 @@ class CameraApiSetup { createChannel.setMessageHandler(nil) } /// Initializes the camera with the given ID. - let initializeChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.initialize\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let initializeChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.initialize\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { initializeChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -794,9 +885,7 @@ class CameraApiSetup { initializeChannel.setMessageHandler(nil) } /// Begins streaming frames from the camera. - let startImageStreamChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.startImageStream\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let startImageStreamChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.startImageStream\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { startImageStreamChannel.setMessageHandler { _, reply in api.startImageStream { result in @@ -812,9 +901,7 @@ class CameraApiSetup { startImageStreamChannel.setMessageHandler(nil) } /// Stops streaming frames from the camera. - let stopImageStreamChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.stopImageStream\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let stopImageStreamChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.stopImageStream\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { stopImageStreamChannel.setMessageHandler { _, reply in api.stopImageStream { result in @@ -833,10 +920,7 @@ class CameraApiSetup { /// frame sent. /// /// This is used to throttle sending frames across the channel. - let receivedImageStreamDataChannel = FlutterBasicMessageChannel( - name: - "dev.flutter.pigeon.camera_avfoundation.CameraApi.receivedImageStreamData\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let receivedImageStreamDataChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.receivedImageStreamData\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { receivedImageStreamDataChannel.setMessageHandler { _, reply in api.receivedImageStreamData { result in @@ -853,9 +937,7 @@ class CameraApiSetup { } /// Indicates that the given camera is no longer being used on the Dart side, /// and any associated resources can be cleaned up. - let disposeChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.dispose\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let disposeChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.dispose\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { disposeChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -873,10 +955,7 @@ class CameraApiSetup { disposeChannel.setMessageHandler(nil) } /// Locks the camera capture to the current device orientation. - let lockCaptureOrientationChannel = FlutterBasicMessageChannel( - name: - "dev.flutter.pigeon.camera_avfoundation.CameraApi.lockCaptureOrientation\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let lockCaptureOrientationChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.lockCaptureOrientation\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { lockCaptureOrientationChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -895,10 +974,7 @@ class CameraApiSetup { } /// Unlocks camera capture orientation, allowing it to automatically adapt to /// device orientation. - let unlockCaptureOrientationChannel = FlutterBasicMessageChannel( - name: - "dev.flutter.pigeon.camera_avfoundation.CameraApi.unlockCaptureOrientation\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let unlockCaptureOrientationChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.unlockCaptureOrientation\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { unlockCaptureOrientationChannel.setMessageHandler { _, reply in api.unlockCaptureOrientation { result in @@ -915,9 +991,7 @@ class CameraApiSetup { } /// Takes a picture with the current settings, and returns the path to the /// resulting file. - let takePictureChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.takePicture\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let takePictureChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.takePicture\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { takePictureChannel.setMessageHandler { _, reply in api.takePicture { result in @@ -933,10 +1007,7 @@ class CameraApiSetup { takePictureChannel.setMessageHandler(nil) } /// Does any preprocessing necessary before beginning to record video. - let prepareForVideoRecordingChannel = FlutterBasicMessageChannel( - name: - "dev.flutter.pigeon.camera_avfoundation.CameraApi.prepareForVideoRecording\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let prepareForVideoRecordingChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.prepareForVideoRecording\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { prepareForVideoRecordingChannel.setMessageHandler { _, reply in api.prepareForVideoRecording { result in @@ -953,9 +1024,7 @@ class CameraApiSetup { } /// Begins recording video, optionally enabling streaming to Dart at the same /// time. - let startVideoRecordingChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.startVideoRecording\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let startVideoRecordingChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.startVideoRecording\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { startVideoRecordingChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -973,9 +1042,7 @@ class CameraApiSetup { startVideoRecordingChannel.setMessageHandler(nil) } /// Stops recording video, and results the path to the resulting file. - let stopVideoRecordingChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.stopVideoRecording\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let stopVideoRecordingChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.stopVideoRecording\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { stopVideoRecordingChannel.setMessageHandler { _, reply in api.stopVideoRecording { result in @@ -991,9 +1058,7 @@ class CameraApiSetup { stopVideoRecordingChannel.setMessageHandler(nil) } /// Pauses video recording. - let pauseVideoRecordingChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.pauseVideoRecording\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let pauseVideoRecordingChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.pauseVideoRecording\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { pauseVideoRecordingChannel.setMessageHandler { _, reply in api.pauseVideoRecording { result in @@ -1009,9 +1074,7 @@ class CameraApiSetup { pauseVideoRecordingChannel.setMessageHandler(nil) } /// Resumes a previously paused video recording. - let resumeVideoRecordingChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.resumeVideoRecording\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let resumeVideoRecordingChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.resumeVideoRecording\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { resumeVideoRecordingChannel.setMessageHandler { _, reply in api.resumeVideoRecording { result in @@ -1027,9 +1090,7 @@ class CameraApiSetup { resumeVideoRecordingChannel.setMessageHandler(nil) } /// Switches the camera to the given flash mode. - let setFlashModeChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setFlashMode\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let setFlashModeChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setFlashMode\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { setFlashModeChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -1047,9 +1108,7 @@ class CameraApiSetup { setFlashModeChannel.setMessageHandler(nil) } /// Switches the camera to the given exposure mode. - let setExposureModeChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setExposureMode\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let setExposureModeChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setExposureMode\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { setExposureModeChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -1069,9 +1128,7 @@ class CameraApiSetup { /// Anchors auto-exposure to the given point in (0,1) coordinate space. /// /// A null value resets to the default exposure point. - let setExposurePointChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setExposurePoint\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let setExposurePointChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setExposurePoint\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { setExposurePointChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -1089,9 +1146,7 @@ class CameraApiSetup { setExposurePointChannel.setMessageHandler(nil) } /// Returns the minimum exposure offset supported by the camera. - let getMinExposureOffsetChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.getMinExposureOffset\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let getMinExposureOffsetChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.getMinExposureOffset\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { getMinExposureOffsetChannel.setMessageHandler { _, reply in api.getMinExposureOffset { result in @@ -1107,9 +1162,7 @@ class CameraApiSetup { getMinExposureOffsetChannel.setMessageHandler(nil) } /// Returns the maximum exposure offset supported by the camera. - let getMaxExposureOffsetChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.getMaxExposureOffset\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let getMaxExposureOffsetChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.getMaxExposureOffset\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { getMaxExposureOffsetChannel.setMessageHandler { _, reply in api.getMaxExposureOffset { result in @@ -1125,9 +1178,7 @@ class CameraApiSetup { getMaxExposureOffsetChannel.setMessageHandler(nil) } /// Sets the exposure offset manually to the given value. - let setExposureOffsetChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setExposureOffset\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let setExposureOffsetChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setExposureOffset\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { setExposureOffsetChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -1145,9 +1196,7 @@ class CameraApiSetup { setExposureOffsetChannel.setMessageHandler(nil) } /// Switches the camera to the given focus mode. - let setFocusModeChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setFocusMode\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let setFocusModeChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setFocusMode\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { setFocusModeChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -1167,9 +1216,7 @@ class CameraApiSetup { /// Anchors auto-focus to the given point in (0,1) coordinate space. /// /// A null value resets to the default focus point. - let setFocusPointChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setFocusPoint\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let setFocusPointChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setFocusPoint\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { setFocusPointChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -1187,9 +1234,7 @@ class CameraApiSetup { setFocusPointChannel.setMessageHandler(nil) } /// Returns the minimum zoom level supported by the camera. - let getMinZoomLevelChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.getMinZoomLevel\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let getMinZoomLevelChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.getMinZoomLevel\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { getMinZoomLevelChannel.setMessageHandler { _, reply in api.getMinZoomLevel { result in @@ -1205,9 +1250,7 @@ class CameraApiSetup { getMinZoomLevelChannel.setMessageHandler(nil) } /// Returns the maximum zoom level supported by the camera. - let getMaxZoomLevelChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.getMaxZoomLevel\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let getMaxZoomLevelChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.getMaxZoomLevel\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { getMaxZoomLevelChannel.setMessageHandler { _, reply in api.getMaxZoomLevel { result in @@ -1223,9 +1266,7 @@ class CameraApiSetup { getMaxZoomLevelChannel.setMessageHandler(nil) } /// Sets the zoom factor. - let setZoomLevelChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setZoomLevel\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let setZoomLevelChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setZoomLevel\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { setZoomLevelChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -1243,10 +1284,7 @@ class CameraApiSetup { setZoomLevelChannel.setMessageHandler(nil) } /// Sets the video stabilization mode. - let setVideoStabilizationModeChannel = FlutterBasicMessageChannel( - name: - "dev.flutter.pigeon.camera_avfoundation.CameraApi.setVideoStabilizationMode\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let setVideoStabilizationModeChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setVideoStabilizationMode\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { setVideoStabilizationModeChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -1264,10 +1302,7 @@ class CameraApiSetup { setVideoStabilizationModeChannel.setMessageHandler(nil) } /// Gets if the given video stabilization mode is supported. - let isVideoStabilizationModeSupportedChannel = FlutterBasicMessageChannel( - name: - "dev.flutter.pigeon.camera_avfoundation.CameraApi.isVideoStabilizationModeSupported\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let isVideoStabilizationModeSupportedChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.isVideoStabilizationModeSupported\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { isVideoStabilizationModeSupportedChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -1285,9 +1320,7 @@ class CameraApiSetup { isVideoStabilizationModeSupportedChannel.setMessageHandler(nil) } /// Pauses streaming of preview frames. - let pausePreviewChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.pausePreview\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let pausePreviewChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.pausePreview\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { pausePreviewChannel.setMessageHandler { _, reply in api.pausePreview { result in @@ -1303,9 +1336,7 @@ class CameraApiSetup { pausePreviewChannel.setMessageHandler(nil) } /// Resumes a previously paused preview stream. - let resumePreviewChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.resumePreview\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let resumePreviewChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.resumePreview\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { resumePreviewChannel.setMessageHandler { _, reply in api.resumePreview { result in @@ -1323,10 +1354,7 @@ class CameraApiSetup { /// Changes the camera used while recording video. /// /// This should only be called while video recording is active. - let updateDescriptionWhileRecordingChannel = FlutterBasicMessageChannel( - name: - "dev.flutter.pigeon.camera_avfoundation.CameraApi.updateDescriptionWhileRecording\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let updateDescriptionWhileRecordingChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.updateDescriptionWhileRecording\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { updateDescriptionWhileRecordingChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -1344,9 +1372,7 @@ class CameraApiSetup { updateDescriptionWhileRecordingChannel.setMessageHandler(nil) } /// Sets the file format used for taking pictures. - let setImageFileFormatChannel = FlutterBasicMessageChannel( - name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setImageFileFormat\(channelSuffix)", - binaryMessenger: binaryMessenger, codec: codec) + let setImageFileFormatChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setImageFileFormat\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) if let api = api { setImageFileFormatChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -1416,31 +1442,25 @@ class PigeonEventSink { } class ImageDataStreamStreamHandler: PigeonEventChannelWrapper { - static func register( - with messenger: FlutterBinaryMessenger, - instanceName: String = "", - streamHandler: ImageDataStreamStreamHandler - ) { - var channelName = - "dev.flutter.pigeon.camera_avfoundation.CameraImageStreamEventApi.imageDataStream" + static func register(with messenger: FlutterBinaryMessenger, + instanceName: String = "", + streamHandler: ImageDataStreamStreamHandler) { + var channelName = "dev.flutter.pigeon.camera_avfoundation.CameraImageStreamEventApi.imageDataStream" if !instanceName.isEmpty { channelName += ".\(instanceName)" } let internalStreamHandler = PigeonStreamHandler(wrapper: streamHandler) - let channel = FlutterEventChannel( - name: channelName, binaryMessenger: messenger, codec: messagesPigeonMethodCodec) + let channel = FlutterEventChannel(name: channelName, binaryMessenger: messenger, codec: messagesPigeonMethodCodec) channel.setStreamHandler(internalStreamHandler) } } - + /// Handler for native callbacks that are not tied to a specific camera ID. /// /// Generated protocol from Pigeon that represents Flutter messages that can be called from Swift. protocol CameraGlobalEventApiProtocol { /// Called when the device's physical orientation changes. - func deviceOrientationChanged( - orientation orientationArg: PlatformDeviceOrientation, - completion: @escaping (Result) -> Void) + func deviceOrientationChanged(orientation orientationArg: PlatformDeviceOrientation, completion: @escaping (Result) -> Void) } class CameraGlobalEventApi: CameraGlobalEventApiProtocol { private let binaryMessenger: FlutterBinaryMessenger @@ -1453,14 +1473,9 @@ class CameraGlobalEventApi: CameraGlobalEventApiProtocol { return MessagesPigeonCodec.shared } /// Called when the device's physical orientation changes. - func deviceOrientationChanged( - orientation orientationArg: PlatformDeviceOrientation, - completion: @escaping (Result) -> Void - ) { - let channelName: String = - "dev.flutter.pigeon.camera_avfoundation.CameraGlobalEventApi.deviceOrientationChanged\(messageChannelSuffix)" - let channel = FlutterBasicMessageChannel( - name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func deviceOrientationChanged(orientation orientationArg: PlatformDeviceOrientation, completion: @escaping (Result) -> Void) { + let channelName: String = "dev.flutter.pigeon.camera_avfoundation.CameraGlobalEventApi.deviceOrientationChanged\(messageChannelSuffix)" + let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([orientationArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { completion(.failure(createConnectionError(withChannelName: channelName))) @@ -1484,9 +1499,7 @@ class CameraGlobalEventApi: CameraGlobalEventApiProtocol { /// Generated protocol from Pigeon that represents Flutter messages that can be called from Swift. protocol CameraEventApiProtocol { /// Called when the camera is inialitized for use. - func initialized( - initialState initialStateArg: PlatformCameraState, - completion: @escaping (Result) -> Void) + func initialized(initialState initialStateArg: PlatformCameraState, completion: @escaping (Result) -> Void) /// Called when an error occurs in the camera. /// /// This should be used for errors that occur outside of the context of @@ -1504,14 +1517,9 @@ class CameraEventApi: CameraEventApiProtocol { return MessagesPigeonCodec.shared } /// Called when the camera is inialitized for use. - func initialized( - initialState initialStateArg: PlatformCameraState, - completion: @escaping (Result) -> Void - ) { - let channelName: String = - "dev.flutter.pigeon.camera_avfoundation.CameraEventApi.initialized\(messageChannelSuffix)" - let channel = FlutterBasicMessageChannel( - name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func initialized(initialState initialStateArg: PlatformCameraState, completion: @escaping (Result) -> Void) { + let channelName: String = "dev.flutter.pigeon.camera_avfoundation.CameraEventApi.initialized\(messageChannelSuffix)" + let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([initialStateArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { completion(.failure(createConnectionError(withChannelName: channelName))) @@ -1531,12 +1539,9 @@ class CameraEventApi: CameraEventApiProtocol { /// /// This should be used for errors that occur outside of the context of /// handling a specific HostApi call, such as during streaming. - func error(message messageArg: String, completion: @escaping (Result) -> Void) - { - let channelName: String = - "dev.flutter.pigeon.camera_avfoundation.CameraEventApi.error\(messageChannelSuffix)" - let channel = FlutterBasicMessageChannel( - name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func error(message messageArg: String, completion: @escaping (Result) -> Void) { + let channelName: String = "dev.flutter.pigeon.camera_avfoundation.CameraEventApi.error\(messageChannelSuffix)" + let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([messageArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { completion(.failure(createConnectionError(withChannelName: channelName))) diff --git a/packages/camera/camera_avfoundation/lib/src/avfoundation_camera.dart b/packages/camera/camera_avfoundation/lib/src/avfoundation_camera.dart index 3907ed89219b..b52721464a97 100644 --- a/packages/camera/camera_avfoundation/lib/src/avfoundation_camera.dart +++ b/packages/camera/camera_avfoundation/lib/src/avfoundation_camera.dart @@ -566,6 +566,8 @@ class AVFoundationCamera extends CameraPlatform { return PlatformImageFormatGroup.bgra8888; case ImageFormatGroup.yuv420: return PlatformImageFormatGroup.yuv420; + case ImageFormatGroup.rgba8888: + return PlatformImageFormatGroup.rgba8888; case ImageFormatGroup.jpeg: case ImageFormatGroup.nv21: // Fall through. diff --git a/packages/camera/camera_avfoundation/lib/src/messages.g.dart b/packages/camera/camera_avfoundation/lib/src/messages.g.dart index 46c94d58f8a1..b9f2d2865416 100644 --- a/packages/camera/camera_avfoundation/lib/src/messages.g.dart +++ b/packages/camera/camera_avfoundation/lib/src/messages.g.dart @@ -1,28 +1,44 @@ // Copyright 2013 The Flutter Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Autogenerated from Pigeon (v26.1.5), do not edit directly. +// Autogenerated from Pigeon (v26.3.4), do not edit directly. // See also: https://pub.dev/packages/pigeon -// ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import, unnecessary_parenthesis, prefer_null_aware_operators, omit_local_variable_types, omit_obvious_local_variable_types, unused_shown_name, unnecessary_import, no_leading_underscores_for_local_identifiers +// ignore_for_file: unused_import, unused_shown_name +// ignore_for_file: type=lint import 'dart:async'; -import 'dart:typed_data' show Float64List, Int32List, Int64List, Uint8List; +import 'dart:typed_data' show Float64List, Int32List, Int64List; -import 'package:flutter/foundation.dart' show ReadBuffer, WriteBuffer; import 'package:flutter/services.dart'; +import 'package:meta/meta.dart' show immutable, protected, visibleForTesting; -PlatformException _createConnectionError(String channelName) { - return PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel: "$channelName".', - ); +Object? _extractReplyValueOrThrow( + List? replyList, + String channelName, { + required bool isNullValid, +}) { + if (replyList == null) { + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel: "$channelName".', + ); + } else if (replyList.length > 1) { + throw PlatformException( + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], + ); + } else if (!isNullValid && (replyList.isNotEmpty && replyList[0] == null)) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } + return replyList.firstOrNull; } -List wrapResponse({ - Object? result, - PlatformException? error, - bool empty = false, -}) { + +List wrapResponse({Object? result, PlatformException? error, bool empty = false}) { if (empty) { return []; } @@ -31,32 +47,74 @@ List wrapResponse({ } return [error.code, error.message, error.details]; } - bool _deepEquals(Object? a, Object? b) { + if (identical(a, b)) { + return true; + } + if (a is double && b is double) { + if (a.isNaN && b.isNaN) { + return true; + } + return a == b; + } if (a is List && b is List) { return a.length == b.length && - a.indexed.every( - ((int, dynamic) item) => _deepEquals(item.$2, b[item.$1]), - ); + a.indexed + .every(((int, dynamic) item) => _deepEquals(item.$2, b[item.$1])); } if (a is Map && b is Map) { - return a.length == b.length && - a.entries.every( - (MapEntry entry) => - (b as Map).containsKey(entry.key) && - _deepEquals(entry.value, b[entry.key]), - ); + if (a.length != b.length) { + return false; + } + for (final MapEntry entryA in a.entries) { + bool found = false; + for (final MapEntry entryB in b.entries) { + if (_deepEquals(entryA.key, entryB.key)) { + if (_deepEquals(entryA.value, entryB.value)) { + found = true; + break; + } else { + return false; + } + } + } + if (!found) { + return false; + } + } + return true; } return a == b; } +int _deepHash(Object? value) { + if (value is List) { + return Object.hashAll(value.map(_deepHash)); + } + if (value is Map) { + int result = 0; + for (final MapEntry entry in value.entries) { + result += (_deepHash(entry.key) * 31) ^ _deepHash(entry.value); + } + return result; + } + if (value is double && value.isNaN) { + // Normalize NaN to a consistent hash. + return 0x7FF8000000000000.hashCode; + } + if (value is double && value == 0.0) { + // Normalize -0.0 to 0.0 so they have the same hash code. + return 0.0.hashCode; + } + return value.hashCode; +} + + enum PlatformCameraLensDirection { /// Front facing camera (a user looking at the screen is seen by the camera). front, - /// Back facing camera (a user looking at the screen is not seen by the camera). back, - /// External camera which may not be mounted to the device. external, } @@ -64,13 +122,10 @@ enum PlatformCameraLensDirection { enum PlatformCameraLensType { /// A built-in wide-angle camera device type. wide, - /// A built-in camera device type with a longer focal length than a wide-angle camera. telephoto, - /// A built-in camera device type with a shorter focal length than a wide-angle camera. ultraWide, - /// Unknown camera device type. unknown, } @@ -82,18 +137,43 @@ enum PlatformDeviceOrientation { landscapeRight, } -enum PlatformExposureMode { auto, locked } +enum PlatformExposureMode { + auto, + locked, +} -enum PlatformFlashMode { off, auto, always, torch } +enum PlatformFlashMode { + off, + auto, + always, + torch, +} -enum PlatformFocusMode { auto, locked } +enum PlatformFocusMode { + auto, + locked, +} /// Pigeon version of ImageFileFormat. -enum PlatformImageFileFormat { jpeg, heif } +enum PlatformImageFileFormat { + jpeg, + heif, +} -enum PlatformImageFormatGroup { bgra8888, yuv420 } +enum PlatformImageFormatGroup { + bgra8888, + yuv420, + rgba8888, +} -enum PlatformResolutionPreset { low, medium, high, veryHigh, ultraHigh, max } +enum PlatformResolutionPreset { + low, + medium, + high, + veryHigh, + ultraHigh, + max, +} enum PlatformVideoStabilizationMode { off, @@ -119,12 +199,15 @@ class PlatformCameraDescription { PlatformCameraLensType lensType; List _toList() { - return [name, lensDirection, lensType]; + return [ + name, + lensDirection, + lensType, + ]; } Object encode() { - return _toList(); - } + return _toList(); } static PlatformCameraDescription decode(Object result) { result as List; @@ -138,19 +221,18 @@ class PlatformCameraDescription { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes bool operator ==(Object other) { - if (other is! PlatformCameraDescription || - other.runtimeType != runtimeType) { + if (other is! PlatformCameraDescription || other.runtimeType != runtimeType) { return false; } if (identical(this, other)) { return true; } - return _deepEquals(encode(), other.encode()); + return _deepEquals(name, other.name) && _deepEquals(lensDirection, other.lensDirection) && _deepEquals(lensType, other.lensType); } @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()); + int get hashCode => _deepHash([runtimeType, ..._toList()]); } class PlatformCameraState { @@ -188,8 +270,7 @@ class PlatformCameraState { } Object encode() { - return _toList(); - } + return _toList(); } static PlatformCameraState decode(Object result) { result as List; @@ -211,12 +292,12 @@ class PlatformCameraState { if (identical(this, other)) { return true; } - return _deepEquals(encode(), other.encode()); + return _deepEquals(previewSize, other.previewSize) && _deepEquals(exposureMode, other.exposureMode) && _deepEquals(focusMode, other.focusMode) && _deepEquals(exposurePointSupported, other.exposurePointSupported) && _deepEquals(focusPointSupported, other.focusPointSupported); } @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()); + int get hashCode => _deepHash([runtimeType, ..._toList()]); } class PlatformCameraImageData { @@ -258,8 +339,7 @@ class PlatformCameraImageData { } Object encode() { - return _toList(); - } + return _toList(); } static PlatformCameraImageData decode(Object result) { result as List; @@ -267,7 +347,7 @@ class PlatformCameraImageData { formatCode: result[0]! as int, width: result[1]! as int, height: result[2]! as int, - planes: (result[3] as List?)!.cast(), + planes: (result[3]! as List).cast(), lensAperture: result[4]! as double, sensorExposureTimeNanoseconds: result[5]! as int, sensorSensitivity: result[6]! as double, @@ -283,12 +363,12 @@ class PlatformCameraImageData { if (identical(this, other)) { return true; } - return _deepEquals(encode(), other.encode()); + return _deepEquals(formatCode, other.formatCode) && _deepEquals(width, other.width) && _deepEquals(height, other.height) && _deepEquals(planes, other.planes) && _deepEquals(lensAperture, other.lensAperture) && _deepEquals(sensorExposureTimeNanoseconds, other.sensorExposureTimeNanoseconds) && _deepEquals(sensorSensitivity, other.sensorSensitivity); } @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()); + int get hashCode => _deepHash([runtimeType, ..._toList()]); } class PlatformCameraImagePlane { @@ -308,12 +388,16 @@ class PlatformCameraImagePlane { int height; List _toList() { - return [bytes, bytesPerRow, width, height]; + return [ + bytes, + bytesPerRow, + width, + height, + ]; } Object encode() { - return _toList(); - } + return _toList(); } static PlatformCameraImagePlane decode(Object result) { result as List; @@ -328,19 +412,18 @@ class PlatformCameraImagePlane { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes bool operator ==(Object other) { - if (other is! PlatformCameraImagePlane || - other.runtimeType != runtimeType) { + if (other is! PlatformCameraImagePlane || other.runtimeType != runtimeType) { return false; } if (identical(this, other)) { return true; } - return _deepEquals(encode(), other.encode()); + return _deepEquals(bytes, other.bytes) && _deepEquals(bytesPerRow, other.bytesPerRow) && _deepEquals(width, other.width) && _deepEquals(height, other.height); } @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()); + int get hashCode => _deepHash([runtimeType, ..._toList()]); } class PlatformMediaSettings { @@ -373,8 +456,7 @@ class PlatformMediaSettings { } Object encode() { - return _toList(); - } + return _toList(); } static PlatformMediaSettings decode(Object result) { result as List; @@ -396,32 +478,40 @@ class PlatformMediaSettings { if (identical(this, other)) { return true; } - return _deepEquals(encode(), other.encode()); + return _deepEquals(resolutionPreset, other.resolutionPreset) && _deepEquals(framesPerSecond, other.framesPerSecond) && _deepEquals(videoBitrate, other.videoBitrate) && _deepEquals(audioBitrate, other.audioBitrate) && _deepEquals(enableAudio, other.enableAudio); } @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()); + int get hashCode => _deepHash([runtimeType, ..._toList()]); } class PlatformPoint { - PlatformPoint({required this.x, required this.y}); + PlatformPoint({ + required this.x, + required this.y, + }); double x; double y; List _toList() { - return [x, y]; + return [ + x, + y, + ]; } Object encode() { - return _toList(); - } + return _toList(); } static PlatformPoint decode(Object result) { result as List; - return PlatformPoint(x: result[0]! as double, y: result[1]! as double); + return PlatformPoint( + x: result[0]! as double, + y: result[1]! as double, + ); } @override @@ -433,28 +523,33 @@ class PlatformPoint { if (identical(this, other)) { return true; } - return _deepEquals(encode(), other.encode()); + return _deepEquals(x, other.x) && _deepEquals(y, other.y); } @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()); + int get hashCode => _deepHash([runtimeType, ..._toList()]); } class PlatformSize { - PlatformSize({required this.width, required this.height}); + PlatformSize({ + required this.width, + required this.height, + }); double width; double height; List _toList() { - return [width, height]; + return [ + width, + height, + ]; } Object encode() { - return _toList(); - } + return _toList(); } static PlatformSize decode(Object result) { result as List; @@ -473,14 +568,15 @@ class PlatformSize { if (identical(this, other)) { return true; } - return _deepEquals(encode(), other.encode()); + return _deepEquals(width, other.width) && _deepEquals(height, other.height); } @override // ignore: avoid_equals_and_hash_code_on_mutable_classes - int get hashCode => Object.hashAll(_toList()); + int get hashCode => _deepHash([runtimeType, ..._toList()]); } + class _PigeonCodec extends StandardMessageCodec { const _PigeonCodec(); @override @@ -488,55 +584,55 @@ class _PigeonCodec extends StandardMessageCodec { if (value is int) { buffer.putUint8(4); buffer.putInt64(value); - } else if (value is PlatformCameraLensDirection) { + } else if (value is PlatformCameraLensDirection) { buffer.putUint8(129); writeValue(buffer, value.index); - } else if (value is PlatformCameraLensType) { + } else if (value is PlatformCameraLensType) { buffer.putUint8(130); writeValue(buffer, value.index); - } else if (value is PlatformDeviceOrientation) { + } else if (value is PlatformDeviceOrientation) { buffer.putUint8(131); writeValue(buffer, value.index); - } else if (value is PlatformExposureMode) { + } else if (value is PlatformExposureMode) { buffer.putUint8(132); writeValue(buffer, value.index); - } else if (value is PlatformFlashMode) { + } else if (value is PlatformFlashMode) { buffer.putUint8(133); writeValue(buffer, value.index); - } else if (value is PlatformFocusMode) { + } else if (value is PlatformFocusMode) { buffer.putUint8(134); writeValue(buffer, value.index); - } else if (value is PlatformImageFileFormat) { + } else if (value is PlatformImageFileFormat) { buffer.putUint8(135); writeValue(buffer, value.index); - } else if (value is PlatformImageFormatGroup) { + } else if (value is PlatformImageFormatGroup) { buffer.putUint8(136); writeValue(buffer, value.index); - } else if (value is PlatformResolutionPreset) { + } else if (value is PlatformResolutionPreset) { buffer.putUint8(137); writeValue(buffer, value.index); - } else if (value is PlatformVideoStabilizationMode) { + } else if (value is PlatformVideoStabilizationMode) { buffer.putUint8(138); writeValue(buffer, value.index); - } else if (value is PlatformCameraDescription) { + } else if (value is PlatformCameraDescription) { buffer.putUint8(139); writeValue(buffer, value.encode()); - } else if (value is PlatformCameraState) { + } else if (value is PlatformCameraState) { buffer.putUint8(140); writeValue(buffer, value.encode()); - } else if (value is PlatformCameraImageData) { + } else if (value is PlatformCameraImageData) { buffer.putUint8(141); writeValue(buffer, value.encode()); - } else if (value is PlatformCameraImagePlane) { + } else if (value is PlatformCameraImagePlane) { buffer.putUint8(142); writeValue(buffer, value.encode()); - } else if (value is PlatformMediaSettings) { + } else if (value is PlatformMediaSettings) { buffer.putUint8(143); writeValue(buffer, value.encode()); - } else if (value is PlatformPoint) { + } else if (value is PlatformPoint) { buffer.putUint8(144); writeValue(buffer, value.encode()); - } else if (value is PlatformSize) { + } else if (value is PlatformSize) { buffer.putUint8(145); writeValue(buffer, value.encode()); } else { @@ -576,9 +672,7 @@ class _PigeonCodec extends StandardMessageCodec { return value == null ? null : PlatformResolutionPreset.values[value]; case 138: final value = readValue(buffer) as int?; - return value == null - ? null - : PlatformVideoStabilizationMode.values[value]; + return value == null ? null : PlatformVideoStabilizationMode.values[value]; case 139: return PlatformCameraDescription.decode(readValue(buffer)!); case 140: @@ -599,21 +693,15 @@ class _PigeonCodec extends StandardMessageCodec { } } -const StandardMethodCodec pigeonMethodCodec = StandardMethodCodec( - _PigeonCodec(), -); +const StandardMethodCodec pigeonMethodCodec = StandardMethodCodec(_PigeonCodec()); class CameraApi { /// Constructor for [CameraApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - CameraApi({ - BinaryMessenger? binaryMessenger, - String messageChannelSuffix = '', - }) : pigeonVar_binaryMessenger = binaryMessenger, - pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty - ? '.$messageChannelSuffix' - : ''; + CameraApi({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) + : pigeonVar_binaryMessenger = binaryMessenger, + pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; final BinaryMessenger? pigeonVar_binaryMessenger; static const MessageCodec pigeonChannelCodec = _PigeonCodec(); @@ -622,8 +710,7 @@ class CameraApi { /// Returns the list of available cameras. Future> getAvailableCameras() async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.getAvailableCameras$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.getAvailableCameras$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -631,89 +718,58 @@ class CameraApi { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send(null); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as List?)! - .cast(); - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ) + ; + return (pigeonVar_replyValue! as List).cast(); } /// Create a new camera with the given settings, and returns its ID. Future create(String cameraName, PlatformMediaSettings settings) async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.create$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.create$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send( - [cameraName, settings], - ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([cameraName, settings]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as int?)!; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ) + ; + return pigeonVar_replyValue! as int; } /// Initializes the camera with the given ID. - Future initialize( - int cameraId, - PlatformImageFormatGroup imageFormat, - ) async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.initialize$pigeonVar_messageChannelSuffix'; + Future initialize(int cameraId, PlatformImageFormatGroup imageFormat) async { + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.initialize$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send( - [cameraId, imageFormat], - ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([cameraId, imageFormat]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } /// Begins streaming frames from the camera. Future startImageStream() async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.startImageStream$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.startImageStream$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -721,23 +777,18 @@ class CameraApi { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send(null); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } /// Stops streaming frames from the camera. Future stopImageStream() async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.stopImageStream$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.stopImageStream$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -745,17 +796,13 @@ class CameraApi { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send(null); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } /// Called by the Dart side of the plugin when it has received the last image @@ -763,8 +810,7 @@ class CameraApi { /// /// This is used to throttle sending frames across the channel. Future receivedImageStreamData() async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.receivedImageStreamData$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.receivedImageStreamData$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -772,79 +818,58 @@ class CameraApi { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send(null); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } /// Indicates that the given camera is no longer being used on the Dart side, /// and any associated resources can be cleaned up. Future dispose(int cameraId) async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.dispose$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.dispose$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send( - [cameraId], - ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([cameraId]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } /// Locks the camera capture to the current device orientation. - Future lockCaptureOrientation( - PlatformDeviceOrientation orientation, - ) async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.lockCaptureOrientation$pigeonVar_messageChannelSuffix'; + Future lockCaptureOrientation(PlatformDeviceOrientation orientation) async { + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.lockCaptureOrientation$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send( - [orientation], - ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([orientation]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } /// Unlocks camera capture orientation, allowing it to automatically adapt to /// device orientation. Future unlockCaptureOrientation() async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.unlockCaptureOrientation$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.unlockCaptureOrientation$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -852,24 +877,19 @@ class CameraApi { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send(null); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } /// Takes a picture with the current settings, and returns the path to the /// resulting file. Future takePicture() async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.takePicture$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.takePicture$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -877,28 +897,19 @@ class CameraApi { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send(null); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as String?)!; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ) + ; + return pigeonVar_replyValue! as String; } /// Does any preprocessing necessary before beginning to record video. Future prepareForVideoRecording() async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.prepareForVideoRecording$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.prepareForVideoRecording$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -906,50 +917,38 @@ class CameraApi { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send(null); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } /// Begins recording video, optionally enabling streaming to Dart at the same /// time. Future startVideoRecording(bool enableStream) async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.startVideoRecording$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.startVideoRecording$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send( - [enableStream], - ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([enableStream]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } /// Stops recording video, and results the path to the resulting file. Future stopVideoRecording() async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.stopVideoRecording$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.stopVideoRecording$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -957,28 +956,19 @@ class CameraApi { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send(null); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as String?)!; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ) + ; + return pigeonVar_replyValue! as String; } /// Pauses video recording. Future pauseVideoRecording() async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.pauseVideoRecording$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.pauseVideoRecording$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -986,23 +976,18 @@ class CameraApi { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send(null); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } /// Resumes a previously paused video recording. Future resumeVideoRecording() async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.resumeVideoRecording$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.resumeVideoRecording$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -1010,103 +995,77 @@ class CameraApi { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send(null); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } /// Switches the camera to the given flash mode. Future setFlashMode(PlatformFlashMode mode) async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setFlashMode$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setFlashMode$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send( - [mode], - ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([mode]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } /// Switches the camera to the given exposure mode. Future setExposureMode(PlatformExposureMode mode) async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setExposureMode$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setExposureMode$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send( - [mode], - ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([mode]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } /// Anchors auto-exposure to the given point in (0,1) coordinate space. /// /// A null value resets to the default exposure point. Future setExposurePoint(PlatformPoint? point) async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setExposurePoint$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setExposurePoint$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send( - [point], - ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([point]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } /// Returns the minimum exposure offset supported by the camera. Future getMinExposureOffset() async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.getMinExposureOffset$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.getMinExposureOffset$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -1114,28 +1073,19 @@ class CameraApi { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send(null); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as double?)!; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ) + ; + return pigeonVar_replyValue! as double; } /// Returns the maximum exposure offset supported by the camera. Future getMaxExposureOffset() async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.getMaxExposureOffset$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.getMaxExposureOffset$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -1143,108 +1093,78 @@ class CameraApi { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send(null); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as double?)!; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ) + ; + return pigeonVar_replyValue! as double; } /// Sets the exposure offset manually to the given value. Future setExposureOffset(double offset) async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setExposureOffset$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setExposureOffset$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send( - [offset], - ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([offset]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } /// Switches the camera to the given focus mode. Future setFocusMode(PlatformFocusMode mode) async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setFocusMode$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setFocusMode$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send( - [mode], - ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([mode]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } /// Anchors auto-focus to the given point in (0,1) coordinate space. /// /// A null value resets to the default focus point. Future setFocusPoint(PlatformPoint? point) async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setFocusPoint$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setFocusPoint$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send( - [point], - ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([point]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } /// Returns the minimum zoom level supported by the camera. Future getMinZoomLevel() async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.getMinZoomLevel$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.getMinZoomLevel$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -1252,28 +1172,19 @@ class CameraApi { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send(null); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as double?)!; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ) + ; + return pigeonVar_replyValue! as double; } /// Returns the maximum zoom level supported by the camera. Future getMaxZoomLevel() async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.getMaxZoomLevel$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.getMaxZoomLevel$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -1281,115 +1192,77 @@ class CameraApi { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send(null); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as double?)!; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ) + ; + return pigeonVar_replyValue! as double; } /// Sets the zoom factor. Future setZoomLevel(double zoom) async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setZoomLevel$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setZoomLevel$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send( - [zoom], - ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([zoom]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } /// Sets the video stabilization mode. - Future setVideoStabilizationMode( - PlatformVideoStabilizationMode mode, - ) async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setVideoStabilizationMode$pigeonVar_messageChannelSuffix'; + Future setVideoStabilizationMode(PlatformVideoStabilizationMode mode) async { + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setVideoStabilizationMode$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send( - [mode], - ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([mode]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } /// Gets if the given video stabilization mode is supported. - Future isVideoStabilizationModeSupported( - PlatformVideoStabilizationMode mode, - ) async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.isVideoStabilizationModeSupported$pigeonVar_messageChannelSuffix'; + Future isVideoStabilizationModeSupported(PlatformVideoStabilizationMode mode) async { + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.isVideoStabilizationModeSupported$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send( - [mode], - ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([mode]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else if (pigeonVar_replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (pigeonVar_replyList[0] as bool?)!; - } + + final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ) + ; + return pigeonVar_replyValue! as bool; } /// Pauses streaming of preview frames. Future pausePreview() async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.pausePreview$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.pausePreview$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -1397,23 +1270,18 @@ class CameraApi { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send(null); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } /// Resumes a previously paused preview stream. Future resumePreview() async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.resumePreview$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.resumePreview$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -1421,86 +1289,67 @@ class CameraApi { ); final Future pigeonVar_sendFuture = pigeonVar_channel.send(null); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } /// Changes the camera used while recording video. /// /// This should only be called while video recording is active. Future updateDescriptionWhileRecording(String cameraName) async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.updateDescriptionWhileRecording$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.updateDescriptionWhileRecording$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send( - [cameraName], - ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([cameraName]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } /// Sets the file format used for taking pictures. Future setImageFileFormat(PlatformImageFileFormat format) async { - final pigeonVar_channelName = - 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setImageFileFormat$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setImageFileFormat$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send( - [format], - ); + final Future pigeonVar_sendFuture = pigeonVar_channel.send([format]); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; - if (pigeonVar_replyList == null) { - throw _createConnectionError(pigeonVar_channelName); - } else if (pigeonVar_replyList.length > 1) { - throw PlatformException( - code: pigeonVar_replyList[0]! as String, - message: pigeonVar_replyList[1] as String?, - details: pigeonVar_replyList[2], - ); - } else { - return; - } + + _extractReplyValueOrThrow( + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ) + ; } } -Stream imageDataStream({String instanceName = ''}) { +Stream imageDataStream( {String instanceName = ''}) { if (instanceName.isNotEmpty) { instanceName = '.$instanceName'; } - final EventChannel imageDataStreamChannel = EventChannel( - 'dev.flutter.pigeon.camera_avfoundation.CameraImageStreamEventApi.imageDataStream$instanceName', - pigeonMethodCodec, - ); + final EventChannel imageDataStreamChannel = + EventChannel('dev.flutter.pigeon.camera_avfoundation.CameraImageStreamEventApi.imageDataStream$instanceName', pigeonMethodCodec); return imageDataStreamChannel.receiveBroadcastStream().map((dynamic event) { return event as PlatformCameraImageData; }); } + /// Handler for native callbacks that are not tied to a specific camera ID. abstract class CameraGlobalEventApi { @@ -1509,44 +1358,25 @@ abstract class CameraGlobalEventApi { /// Called when the device's physical orientation changes. void deviceOrientationChanged(PlatformDeviceOrientation orientation); - static void setUp( - CameraGlobalEventApi? api, { - BinaryMessenger? binaryMessenger, - String messageChannelSuffix = '', - }) { - messageChannelSuffix = messageChannelSuffix.isNotEmpty - ? '.$messageChannelSuffix' - : ''; + static void setUp(CameraGlobalEventApi? api, {BinaryMessenger? binaryMessenger, String messageChannelSuffix = '',}) { + messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; { final pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.camera_avfoundation.CameraGlobalEventApi.deviceOrientationChanged$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger, - ); + 'dev.flutter.pigeon.camera_avfoundation.CameraGlobalEventApi.deviceOrientationChanged$messageChannelSuffix', pigeonChannelCodec, + binaryMessenger: binaryMessenger); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.camera_avfoundation.CameraGlobalEventApi.deviceOrientationChanged was null.', - ); - final List args = (message as List?)!; - final PlatformDeviceOrientation? arg_orientation = - (args[0] as PlatformDeviceOrientation?); - assert( - arg_orientation != null, - 'Argument for dev.flutter.pigeon.camera_avfoundation.CameraGlobalEventApi.deviceOrientationChanged was null, expected non-null PlatformDeviceOrientation.', - ); + final List args = message! as List; + final PlatformDeviceOrientation arg_orientation = args[0]! as PlatformDeviceOrientation; try { - api.deviceOrientationChanged(arg_orientation!); + api.deviceOrientationChanged(arg_orientation); return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse( - error: PlatformException(code: 'error', message: e.toString()), - ); + } catch (e) { + return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); } }); } @@ -1569,77 +1399,46 @@ abstract class CameraEventApi { /// handling a specific HostApi call, such as during streaming. void error(String message); - static void setUp( - CameraEventApi? api, { - BinaryMessenger? binaryMessenger, - String messageChannelSuffix = '', - }) { - messageChannelSuffix = messageChannelSuffix.isNotEmpty - ? '.$messageChannelSuffix' - : ''; + static void setUp(CameraEventApi? api, {BinaryMessenger? binaryMessenger, String messageChannelSuffix = '',}) { + messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; { final pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.camera_avfoundation.CameraEventApi.initialized$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger, - ); + 'dev.flutter.pigeon.camera_avfoundation.CameraEventApi.initialized$messageChannelSuffix', pigeonChannelCodec, + binaryMessenger: binaryMessenger); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.camera_avfoundation.CameraEventApi.initialized was null.', - ); - final List args = (message as List?)!; - final PlatformCameraState? arg_initialState = - (args[0] as PlatformCameraState?); - assert( - arg_initialState != null, - 'Argument for dev.flutter.pigeon.camera_avfoundation.CameraEventApi.initialized was null, expected non-null PlatformCameraState.', - ); + final List args = message! as List; + final PlatformCameraState arg_initialState = args[0]! as PlatformCameraState; try { - api.initialized(arg_initialState!); + api.initialized(arg_initialState); return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse( - error: PlatformException(code: 'error', message: e.toString()), - ); + } catch (e) { + return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); } }); } } { final pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.camera_avfoundation.CameraEventApi.error$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger, - ); + 'dev.flutter.pigeon.camera_avfoundation.CameraEventApi.error$messageChannelSuffix', pigeonChannelCodec, + binaryMessenger: binaryMessenger); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert( - message != null, - 'Argument for dev.flutter.pigeon.camera_avfoundation.CameraEventApi.error was null.', - ); - final List args = (message as List?)!; - final String? arg_message = (args[0] as String?); - assert( - arg_message != null, - 'Argument for dev.flutter.pigeon.camera_avfoundation.CameraEventApi.error was null, expected non-null String.', - ); + final List args = message! as List; + final String arg_message = args[0]! as String; try { - api.error(arg_message!); + api.error(arg_message); return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse( - error: PlatformException(code: 'error', message: e.toString()), - ); + } catch (e) { + return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); } }); } diff --git a/packages/camera/camera_avfoundation/lib/src/type_conversion.dart b/packages/camera/camera_avfoundation/lib/src/type_conversion.dart index 7753f054b007..b53cea2fc809 100644 --- a/packages/camera/camera_avfoundation/lib/src/type_conversion.dart +++ b/packages/camera/camera_avfoundation/lib/src/type_conversion.dart @@ -39,6 +39,9 @@ ImageFormatGroup _imageFormatGroupFromPlatformImageFormat(int data) { case 1111970369: // kCVPixelFormatType_32BGRA return ImageFormatGroup.bgra8888; + + case 1380401729: // kCVPixelFormatType_32RGBA + return ImageFormatGroup.rgba8888; } return ImageFormatGroup.unknown; diff --git a/packages/camera/camera_avfoundation/pigeons/messages.dart b/packages/camera/camera_avfoundation/pigeons/messages.dart index b4976758cf47..da905c182b43 100644 --- a/packages/camera/camera_avfoundation/pigeons/messages.dart +++ b/packages/camera/camera_avfoundation/pigeons/messages.dart @@ -60,7 +60,7 @@ enum PlatformFocusMode { auto, locked } enum PlatformImageFileFormat { jpeg, heif } // Pigeon version of the subset of ImageFormatGroup supported on iOS. -enum PlatformImageFormatGroup { bgra8888, yuv420 } +enum PlatformImageFormatGroup { bgra8888, yuv420, rgba8888 } // Pigeon version of ResolutionPreset. enum PlatformResolutionPreset { low, medium, high, veryHigh, ultraHigh, max } diff --git a/packages/camera/camera_avfoundation/pubspec.yaml b/packages/camera/camera_avfoundation/pubspec.yaml index 8a10d0d21f72..1ccc1ccafaee 100644 --- a/packages/camera/camera_avfoundation/pubspec.yaml +++ b/packages/camera/camera_avfoundation/pubspec.yaml @@ -2,7 +2,7 @@ name: camera_avfoundation description: iOS implementation of the camera plugin. repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_avfoundation issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22 -version: 0.10.1 +version: 0.10.2 environment: sdk: ^3.9.0 @@ -33,3 +33,7 @@ dev_dependencies: topics: - camera +# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. +# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins +dependency_overrides: + camera_platform_interface: {path: ../camera_platform_interface} \ No newline at end of file diff --git a/packages/camera/camera_platform_interface/CHANGELOG.md b/packages/camera/camera_platform_interface/CHANGELOG.md index fc4a7de9d71e..6a73498acf22 100644 --- a/packages/camera/camera_platform_interface/CHANGELOG.md +++ b/packages/camera/camera_platform_interface/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.14.0 + +* Adds `rgba8888` to `ImageFormatGroup` enum. + ## 2.13.0 * Updates minimum supported SDK version to Flutter 3.35/Dart 3.9. diff --git a/packages/camera/camera_platform_interface/lib/src/types/image_format_group.dart b/packages/camera/camera_platform_interface/lib/src/types/image_format_group.dart index 04974ec8bd57..dbb4e73c0778 100644 --- a/packages/camera/camera_platform_interface/lib/src/types/image_format_group.dart +++ b/packages/camera/camera_platform_interface/lib/src/types/image_format_group.dart @@ -37,6 +37,15 @@ enum ImageFormatGroup { /// On Android, this is `android.graphics.ImageFormat.NV21`. See /// https://developer.android.com/reference/android/graphics/ImageFormat#NV21 nv21, + + /// 32-bit RGBA. + /// + /// On Android, this is `android.graphics.ImageFormat.FLEX_RGBA_8888`. See + /// https://developer.android.com/reference/android/graphics/ImageFormat#FLEX_RGBA_8888 + /// + /// On iOS, this is `kCVPixelFormatType_32RGBA`. See + /// https://developer.apple.com/documentation/corevideo/kcvpixelformattype_32rgba + rgba8888, } /// Extension on [ImageFormatGroup] to stringify the enum @@ -54,6 +63,8 @@ extension ImageFormatGroupName on ImageFormatGroup { return 'jpeg'; case ImageFormatGroup.nv21: return 'nv21'; + case ImageFormatGroup.rgba8888: + return 'rgba8888'; case ImageFormatGroup.unknown: return 'unknown'; } diff --git a/packages/camera/camera_platform_interface/pubspec.yaml b/packages/camera/camera_platform_interface/pubspec.yaml index 8336114d1837..272957c2bbd3 100644 --- a/packages/camera/camera_platform_interface/pubspec.yaml +++ b/packages/camera/camera_platform_interface/pubspec.yaml @@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/camera/camera issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22 # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes -version: 2.13.0 +version: 2.14.0 environment: sdk: ^3.9.0 diff --git a/packages/camera/camera_platform_interface/test/types/image_group_test.dart b/packages/camera/camera_platform_interface/test/types/image_group_test.dart index c6ba9f2cb73e..89dc491498e3 100644 --- a/packages/camera/camera_platform_interface/test/types/image_group_test.dart +++ b/packages/camera/camera_platform_interface/test/types/image_group_test.dart @@ -12,6 +12,7 @@ void main() { expect(ImageFormatGroup.yuv420.name(), 'yuv420'); expect(ImageFormatGroup.jpeg.name(), 'jpeg'); expect(ImageFormatGroup.nv21.name(), 'nv21'); + expect(ImageFormatGroup.rgba8888.name(), 'rgba8888'); expect(ImageFormatGroup.unknown.name(), 'unknown'); }); }); From 56b64ee4aa7775511f7f74fd84fc57d73dec4433 Mon Sep 17 00:00:00 2001 From: Mairramer Date: Fri, 1 May 2026 15:58:26 -0300 Subject: [PATCH 2/4] Add support for RGBA_8888 image format in camera plugin --- packages/camera/camera/CHANGELOG.md | 4 + .../camera/camera/lib/src/camera_image.dart | 6 + packages/camera/camera/pubspec.yaml | 6 +- .../lib/src/android_camera_camerax.dart | 13 +- .../camera_android_camerax/pubspec.yaml | 2 +- .../camera_avfoundation/Messages.swift | 268 +++++-- .../lib/src/messages.g.dart | 751 ++++++++++-------- .../test/type_conversion_test.dart | 22 + .../src/method_channel/type_conversion.dart | 5 + .../lib/src/types/image_format_group.dart | 4 +- 10 files changed, 651 insertions(+), 430 deletions(-) diff --git a/packages/camera/camera/CHANGELOG.md b/packages/camera/camera/CHANGELOG.md index 557e16ea59e4..62b35187d689 100644 --- a/packages/camera/camera/CHANGELOG.md +++ b/packages/camera/camera/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.12.1 + +* Adds support for `ImageFormatGroup.rgba8888` image format. + ## 0.12.0+1 * Makes `Optional.of` constructor `const`. diff --git a/packages/camera/camera/lib/src/camera_image.dart b/packages/camera/camera/lib/src/camera_image.dart index f19bc67462bd..76f3f86a6bf9 100644 --- a/packages/camera/camera/lib/src/camera_image.dart +++ b/packages/camera/camera/lib/src/camera_image.dart @@ -89,6 +89,9 @@ ImageFormatGroup _asImageFormatGroup(dynamic rawFormat) { // android.graphics.ImageFormat.NV21 case 17: return ImageFormatGroup.nv21; + // android.graphics.ImageFormat.FLEX_RGBA_8888 + case 42: + return ImageFormatGroup.rgba8888; } } @@ -100,6 +103,9 @@ ImageFormatGroup _asImageFormatGroup(dynamic rawFormat) { // kCVPixelFormatType_32BGRA case 1111970369: return ImageFormatGroup.bgra8888; + // kCVPixelFormatType_32RGBA + case 1380401729: + return ImageFormatGroup.rgba8888; } } diff --git a/packages/camera/camera/pubspec.yaml b/packages/camera/camera/pubspec.yaml index 2d5967181c32..f352a8f7d2f9 100644 --- a/packages/camera/camera/pubspec.yaml +++ b/packages/camera/camera/pubspec.yaml @@ -4,7 +4,7 @@ description: A Flutter plugin for controlling the camera. Supports previewing Dart. repository: https://github.com/flutter/packages/tree/main/packages/camera/camera issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22 -version: 0.12.0+1 +version: 0.12.1 environment: sdk: ^3.9.0 @@ -21,9 +21,9 @@ flutter: default_package: camera_web dependencies: - camera_android_camerax: ^0.7.0 + camera_android_camerax: ^0.7.3 camera_avfoundation: ^0.10.0 - camera_platform_interface: ^2.12.0 + camera_platform_interface: ^2.14.0 camera_web: ^0.3.3 flutter: sdk: flutter diff --git a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart index 22f2cdc9242e..b5552a900379 100644 --- a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart +++ b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart @@ -12,6 +12,7 @@ import 'package:flutter/services.dart' show DeviceOrientation, PlatformException; import 'package:flutter/widgets.dart' show Texture, Widget, visibleForTesting; import 'package:stream_transform/stream_transform.dart'; + import 'camerax_library.dart'; import 'rotated_preview_delegate.dart'; @@ -184,10 +185,10 @@ class AndroidCameraCameraX extends CameraPlatform { /// See https://developer.android.com/reference/android/graphics/ImageFormat#JPEG. static const int imageProxyFormatJpeg = 256; - /// Constant representing the FLEX_RGBA_8888 image format used by ImageProxy. + /// Constant representing the RGBA_8888 image format used by ImageProxy. /// - /// See https://developer.android.com/reference/android/graphics/ImageFormat#FLEX_RGBA_8888. - static const int imageProxyFormatRgba8888 = 42; + /// See https://developer.android.com/reference/android/graphics/PixelFormat#RGBA_8888. + static const int imageProxyFormatRgba8888 = 1; /// Constant representing the YUV 420 image format used for configuring ImageAnalysis. /// @@ -467,8 +468,8 @@ class AndroidCameraCameraX extends CameraPlatform { /// * Retrieves information about the camera and sends a [CameraInitializedEvent]. /// /// [imageFormatGroup] is used to specify the image format used for image - /// streaming, but CameraX currently only supports YUV_420_888 (the CameraX default), - /// NV21, and RGBA (not supported by Flutter). + /// streaming. CameraX currently supports YUV_420_888 (the CameraX default), + /// NV21, and RGBA8888. @override Future initializeCamera( int cameraId, { @@ -1475,7 +1476,7 @@ class AndroidCameraCameraX extends CameraPlatform { return ImageFormatGroup.nv21; case imageProxyFormatJpeg: // android.graphics.ImageFormat.JPEG return ImageFormatGroup.jpeg; - case imageProxyFormatRgba8888: // android.graphics.ImageFormat.FLEX_RGBA_8888 + case imageProxyFormatRgba8888: // android.graphics.PixelFormat.RGBA_8888 return ImageFormatGroup.rgba8888; } diff --git a/packages/camera/camera_android_camerax/pubspec.yaml b/packages/camera/camera_android_camerax/pubspec.yaml index 2afd3fd33519..31d0c5f02355 100644 --- a/packages/camera/camera_android_camerax/pubspec.yaml +++ b/packages/camera/camera_android_camerax/pubspec.yaml @@ -19,7 +19,7 @@ flutter: dependencies: async: ^2.5.0 - camera_platform_interface: ^2.12.0 + camera_platform_interface: ^2.14.0 flutter: sdk: flutter meta: ^1.7.0 diff --git a/packages/camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/Messages.swift b/packages/camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/Messages.swift index 47b40048e92b..e9f3bf8b24cd 100644 --- a/packages/camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/Messages.swift +++ b/packages/camera/camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/Messages.swift @@ -59,7 +59,9 @@ private func wrapError(_ error: Any) -> [Any?] { } private func createConnectionError(withChannelName channelName: String) -> PigeonError { - return PigeonError(code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.", details: "") + return PigeonError( + code: "channel-error", message: "Unable to establish connection on channel: '\(channelName)'.", + details: "") } private func isNullish(_ value: Any?) -> Bool { @@ -77,7 +79,7 @@ private func doubleEqualsMessages(_ lhs: Double, _ rhs: Double) -> Bool { private func doubleHashMessages(_ value: Double, _ hasher: inout Hasher) { if value.isNaN { - hasher.combine(0x7FF8000000000000) + hasher.combine(0x7FF8_0000_0000_0000) } else { // Normalize -0.0 to 0.0 hasher.combine(value == 0 ? 0 : value) @@ -180,7 +182,6 @@ func deepHashMessages(value: Any?, hasher: inout Hasher) { } } - enum PlatformCameraLensDirection: Int { /// Front facing camera (a user looking at the screen is seen by the camera). case front = 0 @@ -262,7 +263,6 @@ struct PlatformCameraDescription: Hashable { /// The type of the camera lens. var lensType: PlatformCameraLensType - // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> PlatformCameraDescription? { let name = pigeonVar_list[0] as! String @@ -286,7 +286,9 @@ struct PlatformCameraDescription: Hashable { if Swift.type(of: lhs) != Swift.type(of: rhs) { return false } - return deepEqualsMessages(lhs.name, rhs.name) && deepEqualsMessages(lhs.lensDirection, rhs.lensDirection) && deepEqualsMessages(lhs.lensType, rhs.lensType) + return deepEqualsMessages(lhs.name, rhs.name) + && deepEqualsMessages(lhs.lensDirection, rhs.lensDirection) + && deepEqualsMessages(lhs.lensType, rhs.lensType) } func hash(into hasher: inout Hasher) { @@ -310,7 +312,6 @@ struct PlatformCameraState: Hashable { /// Whether setting focus points is supported. var focusPointSupported: Bool - // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> PlatformCameraState? { let previewSize = pigeonVar_list[0] as! PlatformSize @@ -340,7 +341,11 @@ struct PlatformCameraState: Hashable { if Swift.type(of: lhs) != Swift.type(of: rhs) { return false } - return deepEqualsMessages(lhs.previewSize, rhs.previewSize) && deepEqualsMessages(lhs.exposureMode, rhs.exposureMode) && deepEqualsMessages(lhs.focusMode, rhs.focusMode) && deepEqualsMessages(lhs.exposurePointSupported, rhs.exposurePointSupported) && deepEqualsMessages(lhs.focusPointSupported, rhs.focusPointSupported) + return deepEqualsMessages(lhs.previewSize, rhs.previewSize) + && deepEqualsMessages(lhs.exposureMode, rhs.exposureMode) + && deepEqualsMessages(lhs.focusMode, rhs.focusMode) + && deepEqualsMessages(lhs.exposurePointSupported, rhs.exposurePointSupported) + && deepEqualsMessages(lhs.focusPointSupported, rhs.focusPointSupported) } func hash(into hasher: inout Hasher) { @@ -364,7 +369,6 @@ struct PlatformCameraImageData: Hashable { var sensorExposureTimeNanoseconds: Int64 var sensorSensitivity: Double - // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> PlatformCameraImageData? { let formatCode = pigeonVar_list[0] as! Int64 @@ -400,7 +404,12 @@ struct PlatformCameraImageData: Hashable { if Swift.type(of: lhs) != Swift.type(of: rhs) { return false } - return deepEqualsMessages(lhs.formatCode, rhs.formatCode) && deepEqualsMessages(lhs.width, rhs.width) && deepEqualsMessages(lhs.height, rhs.height) && deepEqualsMessages(lhs.planes, rhs.planes) && deepEqualsMessages(lhs.lensAperture, rhs.lensAperture) && deepEqualsMessages(lhs.sensorExposureTimeNanoseconds, rhs.sensorExposureTimeNanoseconds) && deepEqualsMessages(lhs.sensorSensitivity, rhs.sensorSensitivity) + return deepEqualsMessages(lhs.formatCode, rhs.formatCode) + && deepEqualsMessages(lhs.width, rhs.width) && deepEqualsMessages(lhs.height, rhs.height) + && deepEqualsMessages(lhs.planes, rhs.planes) + && deepEqualsMessages(lhs.lensAperture, rhs.lensAperture) + && deepEqualsMessages(lhs.sensorExposureTimeNanoseconds, rhs.sensorExposureTimeNanoseconds) + && deepEqualsMessages(lhs.sensorSensitivity, rhs.sensorSensitivity) } func hash(into hasher: inout Hasher) { @@ -422,7 +431,6 @@ struct PlatformCameraImagePlane: Hashable { var width: Int64 var height: Int64 - // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> PlatformCameraImagePlane? { let bytes = pigeonVar_list[0] as! FlutterStandardTypedData @@ -449,7 +457,9 @@ struct PlatformCameraImagePlane: Hashable { if Swift.type(of: lhs) != Swift.type(of: rhs) { return false } - return deepEqualsMessages(lhs.bytes, rhs.bytes) && deepEqualsMessages(lhs.bytesPerRow, rhs.bytesPerRow) && deepEqualsMessages(lhs.width, rhs.width) && deepEqualsMessages(lhs.height, rhs.height) + return deepEqualsMessages(lhs.bytes, rhs.bytes) + && deepEqualsMessages(lhs.bytesPerRow, rhs.bytesPerRow) + && deepEqualsMessages(lhs.width, rhs.width) && deepEqualsMessages(lhs.height, rhs.height) } func hash(into hasher: inout Hasher) { @@ -469,7 +479,6 @@ struct PlatformMediaSettings: Hashable { var audioBitrate: Int64? = nil var enableAudio: Bool - // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> PlatformMediaSettings? { let resolutionPreset = pigeonVar_list[0] as! PlatformResolutionPreset @@ -499,7 +508,11 @@ struct PlatformMediaSettings: Hashable { if Swift.type(of: lhs) != Swift.type(of: rhs) { return false } - return deepEqualsMessages(lhs.resolutionPreset, rhs.resolutionPreset) && deepEqualsMessages(lhs.framesPerSecond, rhs.framesPerSecond) && deepEqualsMessages(lhs.videoBitrate, rhs.videoBitrate) && deepEqualsMessages(lhs.audioBitrate, rhs.audioBitrate) && deepEqualsMessages(lhs.enableAudio, rhs.enableAudio) + return deepEqualsMessages(lhs.resolutionPreset, rhs.resolutionPreset) + && deepEqualsMessages(lhs.framesPerSecond, rhs.framesPerSecond) + && deepEqualsMessages(lhs.videoBitrate, rhs.videoBitrate) + && deepEqualsMessages(lhs.audioBitrate, rhs.audioBitrate) + && deepEqualsMessages(lhs.enableAudio, rhs.enableAudio) } func hash(into hasher: inout Hasher) { @@ -517,7 +530,6 @@ struct PlatformPoint: Hashable { var x: Double var y: Double - // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> PlatformPoint? { let x = pigeonVar_list[0] as! Double @@ -553,7 +565,6 @@ struct PlatformSize: Hashable { var width: Double var height: Double - // swift-format-ignore: AlwaysUseLowerCamelCase static func fromList(_ pigeonVar_list: [Any?]) -> PlatformSize? { let width = pigeonVar_list[0] as! Double @@ -740,17 +751,22 @@ class MessagesPigeonCodec: FlutterStandardMessageCodec, @unchecked Sendable { static let shared = MessagesPigeonCodec(readerWriter: MessagesPigeonCodecReaderWriter()) } -var messagesPigeonMethodCodec = FlutterStandardMethodCodec(readerWriter: MessagesPigeonCodecReaderWriter()); - +var messagesPigeonMethodCodec = FlutterStandardMethodCodec( + readerWriter: MessagesPigeonCodecReaderWriter()) /// Generated protocol from Pigeon that represents a handler of messages from Flutter. protocol CameraApi { /// Returns the list of available cameras. - func getAvailableCameras(completion: @escaping (Result<[PlatformCameraDescription], Error>) -> Void) + func getAvailableCameras( + completion: @escaping (Result<[PlatformCameraDescription], Error>) -> Void) /// Create a new camera with the given settings, and returns its ID. - func create(cameraName: String, settings: PlatformMediaSettings, completion: @escaping (Result) -> Void) + func create( + cameraName: String, settings: PlatformMediaSettings, + completion: @escaping (Result) -> Void) /// Initializes the camera with the given ID. - func initialize(cameraId: Int64, imageFormat: PlatformImageFormatGroup, completion: @escaping (Result) -> Void) + func initialize( + cameraId: Int64, imageFormat: PlatformImageFormatGroup, + completion: @escaping (Result) -> Void) /// Begins streaming frames from the camera. func startImageStream(completion: @escaping (Result) -> Void) /// Stops streaming frames from the camera. @@ -764,7 +780,8 @@ protocol CameraApi { /// and any associated resources can be cleaned up. func dispose(cameraId: Int64, completion: @escaping (Result) -> Void) /// Locks the camera capture to the current device orientation. - func lockCaptureOrientation(orientation: PlatformDeviceOrientation, completion: @escaping (Result) -> Void) + func lockCaptureOrientation( + orientation: PlatformDeviceOrientation, completion: @escaping (Result) -> Void) /// Unlocks camera capture orientation, allowing it to automatically adapt to /// device orientation. func unlockCaptureOrientation(completion: @escaping (Result) -> Void) @@ -785,7 +802,8 @@ protocol CameraApi { /// Switches the camera to the given flash mode. func setFlashMode(mode: PlatformFlashMode, completion: @escaping (Result) -> Void) /// Switches the camera to the given exposure mode. - func setExposureMode(mode: PlatformExposureMode, completion: @escaping (Result) -> Void) + func setExposureMode( + mode: PlatformExposureMode, completion: @escaping (Result) -> Void) /// Anchors auto-exposure to the given point in (0,1) coordinate space. /// /// A null value resets to the default exposure point. @@ -809,9 +827,11 @@ protocol CameraApi { /// Sets the zoom factor. func setZoomLevel(zoom: Double, completion: @escaping (Result) -> Void) /// Sets the video stabilization mode. - func setVideoStabilizationMode(mode: PlatformVideoStabilizationMode, completion: @escaping (Result) -> Void) + func setVideoStabilizationMode( + mode: PlatformVideoStabilizationMode, completion: @escaping (Result) -> Void) /// Gets if the given video stabilization mode is supported. - func isVideoStabilizationModeSupported(mode: PlatformVideoStabilizationMode, completion: @escaping (Result) -> Void) + func isVideoStabilizationModeSupported( + mode: PlatformVideoStabilizationMode, completion: @escaping (Result) -> Void) /// Pauses streaming of preview frames. func pausePreview(completion: @escaping (Result) -> Void) /// Resumes a previously paused preview stream. @@ -819,19 +839,25 @@ protocol CameraApi { /// Changes the camera used while recording video. /// /// This should only be called while video recording is active. - func updateDescriptionWhileRecording(cameraName: String, completion: @escaping (Result) -> Void) + func updateDescriptionWhileRecording( + cameraName: String, completion: @escaping (Result) -> Void) /// Sets the file format used for taking pictures. - func setImageFileFormat(format: PlatformImageFileFormat, completion: @escaping (Result) -> Void) + func setImageFileFormat( + format: PlatformImageFileFormat, completion: @escaping (Result) -> Void) } /// Generated setup class from Pigeon to handle messages through the `binaryMessenger`. class CameraApiSetup { static var codec: FlutterStandardMessageCodec { MessagesPigeonCodec.shared } /// Sets up an instance of `CameraApi` to handle messages through the `binaryMessenger`. - static func setUp(binaryMessenger: FlutterBinaryMessenger, api: CameraApi?, messageChannelSuffix: String = "") { + static func setUp( + binaryMessenger: FlutterBinaryMessenger, api: CameraApi?, messageChannelSuffix: String = "" + ) { let channelSuffix = messageChannelSuffix.count > 0 ? ".\(messageChannelSuffix)" : "" /// Returns the list of available cameras. - let getAvailableCamerasChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.getAvailableCameras\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let getAvailableCamerasChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.getAvailableCameras\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { getAvailableCamerasChannel.setMessageHandler { _, reply in api.getAvailableCameras { result in @@ -847,7 +873,9 @@ class CameraApiSetup { getAvailableCamerasChannel.setMessageHandler(nil) } /// Create a new camera with the given settings, and returns its ID. - let createChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.create\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let createChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.create\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { createChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -866,7 +894,9 @@ class CameraApiSetup { createChannel.setMessageHandler(nil) } /// Initializes the camera with the given ID. - let initializeChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.initialize\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let initializeChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.initialize\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { initializeChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -885,7 +915,9 @@ class CameraApiSetup { initializeChannel.setMessageHandler(nil) } /// Begins streaming frames from the camera. - let startImageStreamChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.startImageStream\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let startImageStreamChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.startImageStream\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { startImageStreamChannel.setMessageHandler { _, reply in api.startImageStream { result in @@ -901,7 +933,9 @@ class CameraApiSetup { startImageStreamChannel.setMessageHandler(nil) } /// Stops streaming frames from the camera. - let stopImageStreamChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.stopImageStream\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let stopImageStreamChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.stopImageStream\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { stopImageStreamChannel.setMessageHandler { _, reply in api.stopImageStream { result in @@ -920,7 +954,10 @@ class CameraApiSetup { /// frame sent. /// /// This is used to throttle sending frames across the channel. - let receivedImageStreamDataChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.receivedImageStreamData\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let receivedImageStreamDataChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.camera_avfoundation.CameraApi.receivedImageStreamData\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { receivedImageStreamDataChannel.setMessageHandler { _, reply in api.receivedImageStreamData { result in @@ -937,7 +974,9 @@ class CameraApiSetup { } /// Indicates that the given camera is no longer being used on the Dart side, /// and any associated resources can be cleaned up. - let disposeChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.dispose\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let disposeChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.dispose\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { disposeChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -955,7 +994,10 @@ class CameraApiSetup { disposeChannel.setMessageHandler(nil) } /// Locks the camera capture to the current device orientation. - let lockCaptureOrientationChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.lockCaptureOrientation\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let lockCaptureOrientationChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.camera_avfoundation.CameraApi.lockCaptureOrientation\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { lockCaptureOrientationChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -974,7 +1016,10 @@ class CameraApiSetup { } /// Unlocks camera capture orientation, allowing it to automatically adapt to /// device orientation. - let unlockCaptureOrientationChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.unlockCaptureOrientation\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let unlockCaptureOrientationChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.camera_avfoundation.CameraApi.unlockCaptureOrientation\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { unlockCaptureOrientationChannel.setMessageHandler { _, reply in api.unlockCaptureOrientation { result in @@ -991,7 +1036,9 @@ class CameraApiSetup { } /// Takes a picture with the current settings, and returns the path to the /// resulting file. - let takePictureChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.takePicture\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let takePictureChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.takePicture\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { takePictureChannel.setMessageHandler { _, reply in api.takePicture { result in @@ -1007,7 +1054,10 @@ class CameraApiSetup { takePictureChannel.setMessageHandler(nil) } /// Does any preprocessing necessary before beginning to record video. - let prepareForVideoRecordingChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.prepareForVideoRecording\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let prepareForVideoRecordingChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.camera_avfoundation.CameraApi.prepareForVideoRecording\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { prepareForVideoRecordingChannel.setMessageHandler { _, reply in api.prepareForVideoRecording { result in @@ -1024,7 +1074,9 @@ class CameraApiSetup { } /// Begins recording video, optionally enabling streaming to Dart at the same /// time. - let startVideoRecordingChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.startVideoRecording\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let startVideoRecordingChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.startVideoRecording\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { startVideoRecordingChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -1042,7 +1094,9 @@ class CameraApiSetup { startVideoRecordingChannel.setMessageHandler(nil) } /// Stops recording video, and results the path to the resulting file. - let stopVideoRecordingChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.stopVideoRecording\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let stopVideoRecordingChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.stopVideoRecording\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { stopVideoRecordingChannel.setMessageHandler { _, reply in api.stopVideoRecording { result in @@ -1058,7 +1112,9 @@ class CameraApiSetup { stopVideoRecordingChannel.setMessageHandler(nil) } /// Pauses video recording. - let pauseVideoRecordingChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.pauseVideoRecording\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let pauseVideoRecordingChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.pauseVideoRecording\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { pauseVideoRecordingChannel.setMessageHandler { _, reply in api.pauseVideoRecording { result in @@ -1074,7 +1130,9 @@ class CameraApiSetup { pauseVideoRecordingChannel.setMessageHandler(nil) } /// Resumes a previously paused video recording. - let resumeVideoRecordingChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.resumeVideoRecording\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let resumeVideoRecordingChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.resumeVideoRecording\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { resumeVideoRecordingChannel.setMessageHandler { _, reply in api.resumeVideoRecording { result in @@ -1090,7 +1148,9 @@ class CameraApiSetup { resumeVideoRecordingChannel.setMessageHandler(nil) } /// Switches the camera to the given flash mode. - let setFlashModeChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setFlashMode\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let setFlashModeChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setFlashMode\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { setFlashModeChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -1108,7 +1168,9 @@ class CameraApiSetup { setFlashModeChannel.setMessageHandler(nil) } /// Switches the camera to the given exposure mode. - let setExposureModeChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setExposureMode\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let setExposureModeChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setExposureMode\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { setExposureModeChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -1128,7 +1190,9 @@ class CameraApiSetup { /// Anchors auto-exposure to the given point in (0,1) coordinate space. /// /// A null value resets to the default exposure point. - let setExposurePointChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setExposurePoint\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let setExposurePointChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setExposurePoint\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { setExposurePointChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -1146,7 +1210,9 @@ class CameraApiSetup { setExposurePointChannel.setMessageHandler(nil) } /// Returns the minimum exposure offset supported by the camera. - let getMinExposureOffsetChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.getMinExposureOffset\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let getMinExposureOffsetChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.getMinExposureOffset\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { getMinExposureOffsetChannel.setMessageHandler { _, reply in api.getMinExposureOffset { result in @@ -1162,7 +1228,9 @@ class CameraApiSetup { getMinExposureOffsetChannel.setMessageHandler(nil) } /// Returns the maximum exposure offset supported by the camera. - let getMaxExposureOffsetChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.getMaxExposureOffset\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let getMaxExposureOffsetChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.getMaxExposureOffset\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { getMaxExposureOffsetChannel.setMessageHandler { _, reply in api.getMaxExposureOffset { result in @@ -1178,7 +1246,9 @@ class CameraApiSetup { getMaxExposureOffsetChannel.setMessageHandler(nil) } /// Sets the exposure offset manually to the given value. - let setExposureOffsetChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setExposureOffset\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let setExposureOffsetChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setExposureOffset\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { setExposureOffsetChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -1196,7 +1266,9 @@ class CameraApiSetup { setExposureOffsetChannel.setMessageHandler(nil) } /// Switches the camera to the given focus mode. - let setFocusModeChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setFocusMode\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let setFocusModeChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setFocusMode\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { setFocusModeChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -1216,7 +1288,9 @@ class CameraApiSetup { /// Anchors auto-focus to the given point in (0,1) coordinate space. /// /// A null value resets to the default focus point. - let setFocusPointChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setFocusPoint\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let setFocusPointChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setFocusPoint\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { setFocusPointChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -1234,7 +1308,9 @@ class CameraApiSetup { setFocusPointChannel.setMessageHandler(nil) } /// Returns the minimum zoom level supported by the camera. - let getMinZoomLevelChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.getMinZoomLevel\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let getMinZoomLevelChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.getMinZoomLevel\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { getMinZoomLevelChannel.setMessageHandler { _, reply in api.getMinZoomLevel { result in @@ -1250,7 +1326,9 @@ class CameraApiSetup { getMinZoomLevelChannel.setMessageHandler(nil) } /// Returns the maximum zoom level supported by the camera. - let getMaxZoomLevelChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.getMaxZoomLevel\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let getMaxZoomLevelChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.getMaxZoomLevel\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { getMaxZoomLevelChannel.setMessageHandler { _, reply in api.getMaxZoomLevel { result in @@ -1266,7 +1344,9 @@ class CameraApiSetup { getMaxZoomLevelChannel.setMessageHandler(nil) } /// Sets the zoom factor. - let setZoomLevelChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setZoomLevel\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let setZoomLevelChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setZoomLevel\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { setZoomLevelChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -1284,7 +1364,10 @@ class CameraApiSetup { setZoomLevelChannel.setMessageHandler(nil) } /// Sets the video stabilization mode. - let setVideoStabilizationModeChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setVideoStabilizationMode\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let setVideoStabilizationModeChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.camera_avfoundation.CameraApi.setVideoStabilizationMode\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { setVideoStabilizationModeChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -1302,7 +1385,10 @@ class CameraApiSetup { setVideoStabilizationModeChannel.setMessageHandler(nil) } /// Gets if the given video stabilization mode is supported. - let isVideoStabilizationModeSupportedChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.isVideoStabilizationModeSupported\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let isVideoStabilizationModeSupportedChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.camera_avfoundation.CameraApi.isVideoStabilizationModeSupported\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { isVideoStabilizationModeSupportedChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -1320,7 +1406,9 @@ class CameraApiSetup { isVideoStabilizationModeSupportedChannel.setMessageHandler(nil) } /// Pauses streaming of preview frames. - let pausePreviewChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.pausePreview\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let pausePreviewChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.pausePreview\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { pausePreviewChannel.setMessageHandler { _, reply in api.pausePreview { result in @@ -1336,7 +1424,9 @@ class CameraApiSetup { pausePreviewChannel.setMessageHandler(nil) } /// Resumes a previously paused preview stream. - let resumePreviewChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.resumePreview\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let resumePreviewChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.resumePreview\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { resumePreviewChannel.setMessageHandler { _, reply in api.resumePreview { result in @@ -1354,7 +1444,10 @@ class CameraApiSetup { /// Changes the camera used while recording video. /// /// This should only be called while video recording is active. - let updateDescriptionWhileRecordingChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.updateDescriptionWhileRecording\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let updateDescriptionWhileRecordingChannel = FlutterBasicMessageChannel( + name: + "dev.flutter.pigeon.camera_avfoundation.CameraApi.updateDescriptionWhileRecording\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { updateDescriptionWhileRecordingChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -1372,7 +1465,9 @@ class CameraApiSetup { updateDescriptionWhileRecordingChannel.setMessageHandler(nil) } /// Sets the file format used for taking pictures. - let setImageFileFormatChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setImageFileFormat\(channelSuffix)", binaryMessenger: binaryMessenger, codec: codec) + let setImageFileFormatChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.camera_avfoundation.CameraApi.setImageFileFormat\(channelSuffix)", + binaryMessenger: binaryMessenger, codec: codec) if let api = api { setImageFileFormatChannel.setMessageHandler { message, reply in let args = message as! [Any?] @@ -1442,25 +1537,31 @@ class PigeonEventSink { } class ImageDataStreamStreamHandler: PigeonEventChannelWrapper { - static func register(with messenger: FlutterBinaryMessenger, - instanceName: String = "", - streamHandler: ImageDataStreamStreamHandler) { - var channelName = "dev.flutter.pigeon.camera_avfoundation.CameraImageStreamEventApi.imageDataStream" + static func register( + with messenger: FlutterBinaryMessenger, + instanceName: String = "", + streamHandler: ImageDataStreamStreamHandler + ) { + var channelName = + "dev.flutter.pigeon.camera_avfoundation.CameraImageStreamEventApi.imageDataStream" if !instanceName.isEmpty { channelName += ".\(instanceName)" } let internalStreamHandler = PigeonStreamHandler(wrapper: streamHandler) - let channel = FlutterEventChannel(name: channelName, binaryMessenger: messenger, codec: messagesPigeonMethodCodec) + let channel = FlutterEventChannel( + name: channelName, binaryMessenger: messenger, codec: messagesPigeonMethodCodec) channel.setStreamHandler(internalStreamHandler) } } - + /// Handler for native callbacks that are not tied to a specific camera ID. /// /// Generated protocol from Pigeon that represents Flutter messages that can be called from Swift. protocol CameraGlobalEventApiProtocol { /// Called when the device's physical orientation changes. - func deviceOrientationChanged(orientation orientationArg: PlatformDeviceOrientation, completion: @escaping (Result) -> Void) + func deviceOrientationChanged( + orientation orientationArg: PlatformDeviceOrientation, + completion: @escaping (Result) -> Void) } class CameraGlobalEventApi: CameraGlobalEventApiProtocol { private let binaryMessenger: FlutterBinaryMessenger @@ -1473,9 +1574,14 @@ class CameraGlobalEventApi: CameraGlobalEventApiProtocol { return MessagesPigeonCodec.shared } /// Called when the device's physical orientation changes. - func deviceOrientationChanged(orientation orientationArg: PlatformDeviceOrientation, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.camera_avfoundation.CameraGlobalEventApi.deviceOrientationChanged\(messageChannelSuffix)" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func deviceOrientationChanged( + orientation orientationArg: PlatformDeviceOrientation, + completion: @escaping (Result) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.camera_avfoundation.CameraGlobalEventApi.deviceOrientationChanged\(messageChannelSuffix)" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([orientationArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { completion(.failure(createConnectionError(withChannelName: channelName))) @@ -1499,7 +1605,9 @@ class CameraGlobalEventApi: CameraGlobalEventApiProtocol { /// Generated protocol from Pigeon that represents Flutter messages that can be called from Swift. protocol CameraEventApiProtocol { /// Called when the camera is inialitized for use. - func initialized(initialState initialStateArg: PlatformCameraState, completion: @escaping (Result) -> Void) + func initialized( + initialState initialStateArg: PlatformCameraState, + completion: @escaping (Result) -> Void) /// Called when an error occurs in the camera. /// /// This should be used for errors that occur outside of the context of @@ -1517,9 +1625,14 @@ class CameraEventApi: CameraEventApiProtocol { return MessagesPigeonCodec.shared } /// Called when the camera is inialitized for use. - func initialized(initialState initialStateArg: PlatformCameraState, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.camera_avfoundation.CameraEventApi.initialized\(messageChannelSuffix)" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func initialized( + initialState initialStateArg: PlatformCameraState, + completion: @escaping (Result) -> Void + ) { + let channelName: String = + "dev.flutter.pigeon.camera_avfoundation.CameraEventApi.initialized\(messageChannelSuffix)" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([initialStateArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { completion(.failure(createConnectionError(withChannelName: channelName))) @@ -1539,9 +1652,12 @@ class CameraEventApi: CameraEventApiProtocol { /// /// This should be used for errors that occur outside of the context of /// handling a specific HostApi call, such as during streaming. - func error(message messageArg: String, completion: @escaping (Result) -> Void) { - let channelName: String = "dev.flutter.pigeon.camera_avfoundation.CameraEventApi.error\(messageChannelSuffix)" - let channel = FlutterBasicMessageChannel(name: channelName, binaryMessenger: binaryMessenger, codec: codec) + func error(message messageArg: String, completion: @escaping (Result) -> Void) + { + let channelName: String = + "dev.flutter.pigeon.camera_avfoundation.CameraEventApi.error\(messageChannelSuffix)" + let channel = FlutterBasicMessageChannel( + name: channelName, binaryMessenger: binaryMessenger, codec: codec) channel.sendMessage([messageArg] as [Any?]) { response in guard let listResponse = response as? [Any?] else { completion(.failure(createConnectionError(withChannelName: channelName))) diff --git a/packages/camera/camera_avfoundation/lib/src/messages.g.dart b/packages/camera/camera_avfoundation/lib/src/messages.g.dart index b9f2d2865416..3e5ef9b14cb3 100644 --- a/packages/camera/camera_avfoundation/lib/src/messages.g.dart +++ b/packages/camera/camera_avfoundation/lib/src/messages.g.dart @@ -13,9 +13,9 @@ import 'package:flutter/services.dart'; import 'package:meta/meta.dart' show immutable, protected, visibleForTesting; Object? _extractReplyValueOrThrow( - List? replyList, - String channelName, { - required bool isNullValid, + List? replyList, + String channelName, { + required bool isNullValid, }) { if (replyList == null) { throw PlatformException( @@ -37,8 +37,11 @@ Object? _extractReplyValueOrThrow( return replyList.firstOrNull; } - -List wrapResponse({Object? result, PlatformException? error, bool empty = false}) { +List wrapResponse({ + Object? result, + PlatformException? error, + bool empty = false, +}) { if (empty) { return []; } @@ -47,6 +50,7 @@ List wrapResponse({Object? result, PlatformException? error, bool empty } return [error.code, error.message, error.details]; } + bool _deepEquals(Object? a, Object? b) { if (identical(a, b)) { return true; @@ -59,8 +63,9 @@ bool _deepEquals(Object? a, Object? b) { } if (a is List && b is List) { return a.length == b.length && - a.indexed - .every(((int, dynamic) item) => _deepEquals(item.$2, b[item.$1])); + a.indexed.every( + ((int, dynamic) item) => _deepEquals(item.$2, b[item.$1]), + ); } if (a is Map && b is Map) { if (a.length != b.length) { @@ -109,12 +114,13 @@ int _deepHash(Object? value) { return value.hashCode; } - enum PlatformCameraLensDirection { /// Front facing camera (a user looking at the screen is seen by the camera). front, + /// Back facing camera (a user looking at the screen is not seen by the camera). back, + /// External camera which may not be mounted to the device. external, } @@ -122,10 +128,13 @@ enum PlatformCameraLensDirection { enum PlatformCameraLensType { /// A built-in wide-angle camera device type. wide, + /// A built-in camera device type with a longer focal length than a wide-angle camera. telephoto, + /// A built-in camera device type with a shorter focal length than a wide-angle camera. ultraWide, + /// Unknown camera device type. unknown, } @@ -137,43 +146,18 @@ enum PlatformDeviceOrientation { landscapeRight, } -enum PlatformExposureMode { - auto, - locked, -} +enum PlatformExposureMode { auto, locked } -enum PlatformFlashMode { - off, - auto, - always, - torch, -} +enum PlatformFlashMode { off, auto, always, torch } -enum PlatformFocusMode { - auto, - locked, -} +enum PlatformFocusMode { auto, locked } /// Pigeon version of ImageFileFormat. -enum PlatformImageFileFormat { - jpeg, - heif, -} +enum PlatformImageFileFormat { jpeg, heif } -enum PlatformImageFormatGroup { - bgra8888, - yuv420, - rgba8888, -} +enum PlatformImageFormatGroup { bgra8888, yuv420, rgba8888 } -enum PlatformResolutionPreset { - low, - medium, - high, - veryHigh, - ultraHigh, - max, -} +enum PlatformResolutionPreset { low, medium, high, veryHigh, ultraHigh, max } enum PlatformVideoStabilizationMode { off, @@ -199,15 +183,12 @@ class PlatformCameraDescription { PlatformCameraLensType lensType; List _toList() { - return [ - name, - lensDirection, - lensType, - ]; + return [name, lensDirection, lensType]; } Object encode() { - return _toList(); } + return _toList(); + } static PlatformCameraDescription decode(Object result) { result as List; @@ -221,13 +202,16 @@ class PlatformCameraDescription { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes bool operator ==(Object other) { - if (other is! PlatformCameraDescription || other.runtimeType != runtimeType) { + if (other is! PlatformCameraDescription || + other.runtimeType != runtimeType) { return false; } if (identical(this, other)) { return true; } - return _deepEquals(name, other.name) && _deepEquals(lensDirection, other.lensDirection) && _deepEquals(lensType, other.lensType); + return _deepEquals(name, other.name) && + _deepEquals(lensDirection, other.lensDirection) && + _deepEquals(lensType, other.lensType); } @override @@ -270,7 +254,8 @@ class PlatformCameraState { } Object encode() { - return _toList(); } + return _toList(); + } static PlatformCameraState decode(Object result) { result as List; @@ -292,7 +277,11 @@ class PlatformCameraState { if (identical(this, other)) { return true; } - return _deepEquals(previewSize, other.previewSize) && _deepEquals(exposureMode, other.exposureMode) && _deepEquals(focusMode, other.focusMode) && _deepEquals(exposurePointSupported, other.exposurePointSupported) && _deepEquals(focusPointSupported, other.focusPointSupported); + return _deepEquals(previewSize, other.previewSize) && + _deepEquals(exposureMode, other.exposureMode) && + _deepEquals(focusMode, other.focusMode) && + _deepEquals(exposurePointSupported, other.exposurePointSupported) && + _deepEquals(focusPointSupported, other.focusPointSupported); } @override @@ -339,7 +328,8 @@ class PlatformCameraImageData { } Object encode() { - return _toList(); } + return _toList(); + } static PlatformCameraImageData decode(Object result) { result as List; @@ -363,7 +353,16 @@ class PlatformCameraImageData { if (identical(this, other)) { return true; } - return _deepEquals(formatCode, other.formatCode) && _deepEquals(width, other.width) && _deepEquals(height, other.height) && _deepEquals(planes, other.planes) && _deepEquals(lensAperture, other.lensAperture) && _deepEquals(sensorExposureTimeNanoseconds, other.sensorExposureTimeNanoseconds) && _deepEquals(sensorSensitivity, other.sensorSensitivity); + return _deepEquals(formatCode, other.formatCode) && + _deepEquals(width, other.width) && + _deepEquals(height, other.height) && + _deepEquals(planes, other.planes) && + _deepEquals(lensAperture, other.lensAperture) && + _deepEquals( + sensorExposureTimeNanoseconds, + other.sensorExposureTimeNanoseconds, + ) && + _deepEquals(sensorSensitivity, other.sensorSensitivity); } @override @@ -388,16 +387,12 @@ class PlatformCameraImagePlane { int height; List _toList() { - return [ - bytes, - bytesPerRow, - width, - height, - ]; + return [bytes, bytesPerRow, width, height]; } Object encode() { - return _toList(); } + return _toList(); + } static PlatformCameraImagePlane decode(Object result) { result as List; @@ -412,13 +407,17 @@ class PlatformCameraImagePlane { @override // ignore: avoid_equals_and_hash_code_on_mutable_classes bool operator ==(Object other) { - if (other is! PlatformCameraImagePlane || other.runtimeType != runtimeType) { + if (other is! PlatformCameraImagePlane || + other.runtimeType != runtimeType) { return false; } if (identical(this, other)) { return true; } - return _deepEquals(bytes, other.bytes) && _deepEquals(bytesPerRow, other.bytesPerRow) && _deepEquals(width, other.width) && _deepEquals(height, other.height); + return _deepEquals(bytes, other.bytes) && + _deepEquals(bytesPerRow, other.bytesPerRow) && + _deepEquals(width, other.width) && + _deepEquals(height, other.height); } @override @@ -456,7 +455,8 @@ class PlatformMediaSettings { } Object encode() { - return _toList(); } + return _toList(); + } static PlatformMediaSettings decode(Object result) { result as List; @@ -478,7 +478,11 @@ class PlatformMediaSettings { if (identical(this, other)) { return true; } - return _deepEquals(resolutionPreset, other.resolutionPreset) && _deepEquals(framesPerSecond, other.framesPerSecond) && _deepEquals(videoBitrate, other.videoBitrate) && _deepEquals(audioBitrate, other.audioBitrate) && _deepEquals(enableAudio, other.enableAudio); + return _deepEquals(resolutionPreset, other.resolutionPreset) && + _deepEquals(framesPerSecond, other.framesPerSecond) && + _deepEquals(videoBitrate, other.videoBitrate) && + _deepEquals(audioBitrate, other.audioBitrate) && + _deepEquals(enableAudio, other.enableAudio); } @override @@ -487,31 +491,23 @@ class PlatformMediaSettings { } class PlatformPoint { - PlatformPoint({ - required this.x, - required this.y, - }); + PlatformPoint({required this.x, required this.y}); double x; double y; List _toList() { - return [ - x, - y, - ]; + return [x, y]; } Object encode() { - return _toList(); } + return _toList(); + } static PlatformPoint decode(Object result) { result as List; - return PlatformPoint( - x: result[0]! as double, - y: result[1]! as double, - ); + return PlatformPoint(x: result[0]! as double, y: result[1]! as double); } @override @@ -532,24 +528,19 @@ class PlatformPoint { } class PlatformSize { - PlatformSize({ - required this.width, - required this.height, - }); + PlatformSize({required this.width, required this.height}); double width; double height; List _toList() { - return [ - width, - height, - ]; + return [width, height]; } Object encode() { - return _toList(); } + return _toList(); + } static PlatformSize decode(Object result) { result as List; @@ -576,7 +567,6 @@ class PlatformSize { int get hashCode => _deepHash([runtimeType, ..._toList()]); } - class _PigeonCodec extends StandardMessageCodec { const _PigeonCodec(); @override @@ -584,55 +574,55 @@ class _PigeonCodec extends StandardMessageCodec { if (value is int) { buffer.putUint8(4); buffer.putInt64(value); - } else if (value is PlatformCameraLensDirection) { + } else if (value is PlatformCameraLensDirection) { buffer.putUint8(129); writeValue(buffer, value.index); - } else if (value is PlatformCameraLensType) { + } else if (value is PlatformCameraLensType) { buffer.putUint8(130); writeValue(buffer, value.index); - } else if (value is PlatformDeviceOrientation) { + } else if (value is PlatformDeviceOrientation) { buffer.putUint8(131); writeValue(buffer, value.index); - } else if (value is PlatformExposureMode) { + } else if (value is PlatformExposureMode) { buffer.putUint8(132); writeValue(buffer, value.index); - } else if (value is PlatformFlashMode) { + } else if (value is PlatformFlashMode) { buffer.putUint8(133); writeValue(buffer, value.index); - } else if (value is PlatformFocusMode) { + } else if (value is PlatformFocusMode) { buffer.putUint8(134); writeValue(buffer, value.index); - } else if (value is PlatformImageFileFormat) { + } else if (value is PlatformImageFileFormat) { buffer.putUint8(135); writeValue(buffer, value.index); - } else if (value is PlatformImageFormatGroup) { + } else if (value is PlatformImageFormatGroup) { buffer.putUint8(136); writeValue(buffer, value.index); - } else if (value is PlatformResolutionPreset) { + } else if (value is PlatformResolutionPreset) { buffer.putUint8(137); writeValue(buffer, value.index); - } else if (value is PlatformVideoStabilizationMode) { + } else if (value is PlatformVideoStabilizationMode) { buffer.putUint8(138); writeValue(buffer, value.index); - } else if (value is PlatformCameraDescription) { + } else if (value is PlatformCameraDescription) { buffer.putUint8(139); writeValue(buffer, value.encode()); - } else if (value is PlatformCameraState) { + } else if (value is PlatformCameraState) { buffer.putUint8(140); writeValue(buffer, value.encode()); - } else if (value is PlatformCameraImageData) { + } else if (value is PlatformCameraImageData) { buffer.putUint8(141); writeValue(buffer, value.encode()); - } else if (value is PlatformCameraImagePlane) { + } else if (value is PlatformCameraImagePlane) { buffer.putUint8(142); writeValue(buffer, value.encode()); - } else if (value is PlatformMediaSettings) { + } else if (value is PlatformMediaSettings) { buffer.putUint8(143); writeValue(buffer, value.encode()); - } else if (value is PlatformPoint) { + } else if (value is PlatformPoint) { buffer.putUint8(144); writeValue(buffer, value.encode()); - } else if (value is PlatformSize) { + } else if (value is PlatformSize) { buffer.putUint8(145); writeValue(buffer, value.encode()); } else { @@ -672,7 +662,9 @@ class _PigeonCodec extends StandardMessageCodec { return value == null ? null : PlatformResolutionPreset.values[value]; case 138: final value = readValue(buffer) as int?; - return value == null ? null : PlatformVideoStabilizationMode.values[value]; + return value == null + ? null + : PlatformVideoStabilizationMode.values[value]; case 139: return PlatformCameraDescription.decode(readValue(buffer)!); case 140: @@ -693,15 +685,21 @@ class _PigeonCodec extends StandardMessageCodec { } } -const StandardMethodCodec pigeonMethodCodec = StandardMethodCodec(_PigeonCodec()); +const StandardMethodCodec pigeonMethodCodec = StandardMethodCodec( + _PigeonCodec(), +); class CameraApi { /// Constructor for [CameraApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - CameraApi({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) - : pigeonVar_binaryMessenger = binaryMessenger, - pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + CameraApi({ + BinaryMessenger? binaryMessenger, + String messageChannelSuffix = '', + }) : pigeonVar_binaryMessenger = binaryMessenger, + pigeonVar_messageChannelSuffix = messageChannelSuffix.isNotEmpty + ? '.$messageChannelSuffix' + : ''; final BinaryMessenger? pigeonVar_binaryMessenger; static const MessageCodec pigeonChannelCodec = _PigeonCodec(); @@ -710,7 +708,8 @@ class CameraApi { /// Returns the list of available cameras. Future> getAvailableCameras() async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.getAvailableCameras$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.getAvailableCameras$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -720,56 +719,64 @@ class CameraApi { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: false, - ) - ; - return (pigeonVar_replyValue! as List).cast(); + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); + return (pigeonVar_replyValue! as List) + .cast(); } /// Create a new camera with the given settings, and returns its ID. Future create(String cameraName, PlatformMediaSettings settings) async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.create$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.create$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send([cameraName, settings]); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [cameraName, settings], + ); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: false, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); return pigeonVar_replyValue! as int; } /// Initializes the camera with the given ID. - Future initialize(int cameraId, PlatformImageFormatGroup imageFormat) async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.initialize$pigeonVar_messageChannelSuffix'; + Future initialize( + int cameraId, + PlatformImageFormatGroup imageFormat, + ) async { + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.initialize$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send([cameraId, imageFormat]); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [cameraId, imageFormat], + ); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } /// Begins streaming frames from the camera. Future startImageStream() async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.startImageStream$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.startImageStream$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -779,16 +786,16 @@ class CameraApi { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } /// Stops streaming frames from the camera. Future stopImageStream() async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.stopImageStream$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.stopImageStream$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -798,11 +805,10 @@ class CameraApi { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } /// Called by the Dart side of the plugin when it has received the last image @@ -810,7 +816,8 @@ class CameraApi { /// /// This is used to throttle sending frames across the channel. Future receivedImageStreamData() async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.receivedImageStreamData$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.receivedImageStreamData$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -820,56 +827,62 @@ class CameraApi { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } /// Indicates that the given camera is no longer being used on the Dart side, /// and any associated resources can be cleaned up. Future dispose(int cameraId) async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.dispose$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.dispose$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send([cameraId]); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [cameraId], + ); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } /// Locks the camera capture to the current device orientation. - Future lockCaptureOrientation(PlatformDeviceOrientation orientation) async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.lockCaptureOrientation$pigeonVar_messageChannelSuffix'; + Future lockCaptureOrientation( + PlatformDeviceOrientation orientation, + ) async { + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.lockCaptureOrientation$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send([orientation]); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [orientation], + ); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } /// Unlocks camera capture orientation, allowing it to automatically adapt to /// device orientation. Future unlockCaptureOrientation() async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.unlockCaptureOrientation$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.unlockCaptureOrientation$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -879,17 +892,17 @@ class CameraApi { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } /// Takes a picture with the current settings, and returns the path to the /// resulting file. Future takePicture() async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.takePicture$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.takePicture$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -899,17 +912,17 @@ class CameraApi { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: false, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); return pigeonVar_replyValue! as String; } /// Does any preprocessing necessary before beginning to record video. Future prepareForVideoRecording() async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.prepareForVideoRecording$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.prepareForVideoRecording$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -919,36 +932,38 @@ class CameraApi { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } /// Begins recording video, optionally enabling streaming to Dart at the same /// time. Future startVideoRecording(bool enableStream) async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.startVideoRecording$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.startVideoRecording$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send([enableStream]); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [enableStream], + ); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } /// Stops recording video, and results the path to the resulting file. Future stopVideoRecording() async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.stopVideoRecording$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.stopVideoRecording$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -958,17 +973,17 @@ class CameraApi { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: false, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); return pigeonVar_replyValue! as String; } /// Pauses video recording. Future pauseVideoRecording() async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.pauseVideoRecording$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.pauseVideoRecording$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -978,16 +993,16 @@ class CameraApi { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } /// Resumes a previously paused video recording. Future resumeVideoRecording() async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.resumeVideoRecording$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.resumeVideoRecording$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -997,75 +1012,81 @@ class CameraApi { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } /// Switches the camera to the given flash mode. Future setFlashMode(PlatformFlashMode mode) async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setFlashMode$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setFlashMode$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send([mode]); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [mode], + ); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } /// Switches the camera to the given exposure mode. Future setExposureMode(PlatformExposureMode mode) async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setExposureMode$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setExposureMode$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send([mode]); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [mode], + ); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } /// Anchors auto-exposure to the given point in (0,1) coordinate space. /// /// A null value resets to the default exposure point. Future setExposurePoint(PlatformPoint? point) async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setExposurePoint$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setExposurePoint$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send([point]); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [point], + ); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } /// Returns the minimum exposure offset supported by the camera. Future getMinExposureOffset() async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.getMinExposureOffset$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.getMinExposureOffset$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -1075,17 +1096,17 @@ class CameraApi { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: false, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); return pigeonVar_replyValue! as double; } /// Returns the maximum exposure offset supported by the camera. Future getMaxExposureOffset() async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.getMaxExposureOffset$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.getMaxExposureOffset$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -1095,76 +1116,82 @@ class CameraApi { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: false, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); return pigeonVar_replyValue! as double; } /// Sets the exposure offset manually to the given value. Future setExposureOffset(double offset) async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setExposureOffset$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setExposureOffset$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send([offset]); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [offset], + ); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } /// Switches the camera to the given focus mode. Future setFocusMode(PlatformFocusMode mode) async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setFocusMode$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setFocusMode$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send([mode]); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [mode], + ); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } /// Anchors auto-focus to the given point in (0,1) coordinate space. /// /// A null value resets to the default focus point. Future setFocusPoint(PlatformPoint? point) async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setFocusPoint$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setFocusPoint$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send([point]); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [point], + ); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } /// Returns the minimum zoom level supported by the camera. Future getMinZoomLevel() async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.getMinZoomLevel$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.getMinZoomLevel$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -1174,17 +1201,17 @@ class CameraApi { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: false, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); return pigeonVar_replyValue! as double; } /// Returns the maximum zoom level supported by the camera. Future getMaxZoomLevel() async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.getMaxZoomLevel$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.getMaxZoomLevel$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -1194,75 +1221,85 @@ class CameraApi { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: false, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); return pigeonVar_replyValue! as double; } /// Sets the zoom factor. Future setZoomLevel(double zoom) async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setZoomLevel$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setZoomLevel$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send([zoom]); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [zoom], + ); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } /// Sets the video stabilization mode. - Future setVideoStabilizationMode(PlatformVideoStabilizationMode mode) async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setVideoStabilizationMode$pigeonVar_messageChannelSuffix'; + Future setVideoStabilizationMode( + PlatformVideoStabilizationMode mode, + ) async { + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setVideoStabilizationMode$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send([mode]); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [mode], + ); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } /// Gets if the given video stabilization mode is supported. - Future isVideoStabilizationModeSupported(PlatformVideoStabilizationMode mode) async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.isVideoStabilizationModeSupported$pigeonVar_messageChannelSuffix'; + Future isVideoStabilizationModeSupported( + PlatformVideoStabilizationMode mode, + ) async { + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.isVideoStabilizationModeSupported$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send([mode]); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [mode], + ); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; final Object? pigeonVar_replyValue = _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: false, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: false, + ); return pigeonVar_replyValue! as bool; } /// Pauses streaming of preview frames. Future pausePreview() async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.pausePreview$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.pausePreview$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -1272,16 +1309,16 @@ class CameraApi { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } /// Resumes a previously paused preview stream. Future resumePreview() async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.resumePreview$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.resumePreview$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, @@ -1291,65 +1328,69 @@ class CameraApi { final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } /// Changes the camera used while recording video. /// /// This should only be called while video recording is active. Future updateDescriptionWhileRecording(String cameraName) async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.updateDescriptionWhileRecording$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.updateDescriptionWhileRecording$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send([cameraName]); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [cameraName], + ); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } /// Sets the file format used for taking pictures. Future setImageFileFormat(PlatformImageFileFormat format) async { - final pigeonVar_channelName = 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setImageFileFormat$pigeonVar_messageChannelSuffix'; + final pigeonVar_channelName = + 'dev.flutter.pigeon.camera_avfoundation.CameraApi.setImageFileFormat$pigeonVar_messageChannelSuffix'; final pigeonVar_channel = BasicMessageChannel( pigeonVar_channelName, pigeonChannelCodec, binaryMessenger: pigeonVar_binaryMessenger, ); - final Future pigeonVar_sendFuture = pigeonVar_channel.send([format]); + final Future pigeonVar_sendFuture = pigeonVar_channel.send( + [format], + ); final pigeonVar_replyList = await pigeonVar_sendFuture as List?; _extractReplyValueOrThrow( - pigeonVar_replyList, - pigeonVar_channelName, - isNullValid: true, - ) - ; + pigeonVar_replyList, + pigeonVar_channelName, + isNullValid: true, + ); } } -Stream imageDataStream( {String instanceName = ''}) { +Stream imageDataStream({String instanceName = ''}) { if (instanceName.isNotEmpty) { instanceName = '.$instanceName'; } - final EventChannel imageDataStreamChannel = - EventChannel('dev.flutter.pigeon.camera_avfoundation.CameraImageStreamEventApi.imageDataStream$instanceName', pigeonMethodCodec); + final EventChannel imageDataStreamChannel = EventChannel( + 'dev.flutter.pigeon.camera_avfoundation.CameraImageStreamEventApi.imageDataStream$instanceName', + pigeonMethodCodec, + ); return imageDataStreamChannel.receiveBroadcastStream().map((dynamic event) { return event as PlatformCameraImageData; }); } - /// Handler for native callbacks that are not tied to a specific camera ID. abstract class CameraGlobalEventApi { @@ -1358,25 +1399,36 @@ abstract class CameraGlobalEventApi { /// Called when the device's physical orientation changes. void deviceOrientationChanged(PlatformDeviceOrientation orientation); - static void setUp(CameraGlobalEventApi? api, {BinaryMessenger? binaryMessenger, String messageChannelSuffix = '',}) { - messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + static void setUp( + CameraGlobalEventApi? api, { + BinaryMessenger? binaryMessenger, + String messageChannelSuffix = '', + }) { + messageChannelSuffix = messageChannelSuffix.isNotEmpty + ? '.$messageChannelSuffix' + : ''; { final pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.camera_avfoundation.CameraGlobalEventApi.deviceOrientationChanged$messageChannelSuffix', pigeonChannelCodec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.camera_avfoundation.CameraGlobalEventApi.deviceOrientationChanged$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { final List args = message! as List; - final PlatformDeviceOrientation arg_orientation = args[0]! as PlatformDeviceOrientation; + final PlatformDeviceOrientation arg_orientation = + args[0]! as PlatformDeviceOrientation; try { api.deviceOrientationChanged(arg_orientation); return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } @@ -1399,33 +1451,46 @@ abstract class CameraEventApi { /// handling a specific HostApi call, such as during streaming. void error(String message); - static void setUp(CameraEventApi? api, {BinaryMessenger? binaryMessenger, String messageChannelSuffix = '',}) { - messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + static void setUp( + CameraEventApi? api, { + BinaryMessenger? binaryMessenger, + String messageChannelSuffix = '', + }) { + messageChannelSuffix = messageChannelSuffix.isNotEmpty + ? '.$messageChannelSuffix' + : ''; { final pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.camera_avfoundation.CameraEventApi.initialized$messageChannelSuffix', pigeonChannelCodec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.camera_avfoundation.CameraEventApi.initialized$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { final List args = message! as List; - final PlatformCameraState arg_initialState = args[0]! as PlatformCameraState; + final PlatformCameraState arg_initialState = + args[0]! as PlatformCameraState; try { api.initialized(arg_initialState); return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { final pigeonVar_channel = BasicMessageChannel( - 'dev.flutter.pigeon.camera_avfoundation.CameraEventApi.error$messageChannelSuffix', pigeonChannelCodec, - binaryMessenger: binaryMessenger); + 'dev.flutter.pigeon.camera_avfoundation.CameraEventApi.error$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { @@ -1437,8 +1502,10 @@ abstract class CameraEventApi { return wrapResponse(empty: true); } on PlatformException catch (e) { return wrapResponse(error: e); - } catch (e) { - return wrapResponse(error: PlatformException(code: 'error', message: e.toString())); + } catch (e) { + return wrapResponse( + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } diff --git a/packages/camera/camera_avfoundation/test/type_conversion_test.dart b/packages/camera/camera_avfoundation/test/type_conversion_test.dart index 56bea24a084b..20665d12dfa5 100644 --- a/packages/camera/camera_avfoundation/test/type_conversion_test.dart +++ b/packages/camera/camera_avfoundation/test/type_conversion_test.dart @@ -56,4 +56,26 @@ void main() { ); expect(cameraImage.format.group, ImageFormatGroup.yuv420); }); + + test('CameraImageData has ImageFormatGroup.rgba8888', () { + final CameraImageData cameraImage = cameraImageFromPlatformData( + PlatformCameraImageData( + formatCode: 1380401729, + width: 1, + height: 1, + lensAperture: 1.8, + sensorExposureTimeNanoseconds: 9991324, + sensorSensitivity: 92.0, + planes: [ + PlatformCameraImagePlane( + bytes: Uint8List.fromList([1, 2, 3, 4]), + bytesPerRow: 4, + width: 1, + height: 1, + ), + ], + ), + ); + expect(cameraImage.format.group, ImageFormatGroup.rgba8888); + }); } diff --git a/packages/camera/camera_platform_interface/lib/src/method_channel/type_conversion.dart b/packages/camera/camera_platform_interface/lib/src/method_channel/type_conversion.dart index 457d7d00ccb4..44eed0580b6a 100644 --- a/packages/camera/camera_platform_interface/lib/src/method_channel/type_conversion.dart +++ b/packages/camera/camera_platform_interface/lib/src/method_channel/type_conversion.dart @@ -37,6 +37,8 @@ ImageFormatGroup _imageFormatGroupFromPlatformData(dynamic data) { return ImageFormatGroup.yuv420; case 256: // android.graphics.ImageFormat.JPEG return ImageFormatGroup.jpeg; + case 42: // android.graphics.PixelFormat.RGBA_8888 + return ImageFormatGroup.rgba8888; } } @@ -47,6 +49,9 @@ ImageFormatGroup _imageFormatGroupFromPlatformData(dynamic data) { case 1111970369: // kCVPixelFormatType_32BGRA return ImageFormatGroup.bgra8888; + + case 1380401729: // kCVPixelFormatType_32RGBA + return ImageFormatGroup.rgba8888; } } diff --git a/packages/camera/camera_platform_interface/lib/src/types/image_format_group.dart b/packages/camera/camera_platform_interface/lib/src/types/image_format_group.dart index dbb4e73c0778..c213f4b89dce 100644 --- a/packages/camera/camera_platform_interface/lib/src/types/image_format_group.dart +++ b/packages/camera/camera_platform_interface/lib/src/types/image_format_group.dart @@ -40,8 +40,8 @@ enum ImageFormatGroup { /// 32-bit RGBA. /// - /// On Android, this is `android.graphics.ImageFormat.FLEX_RGBA_8888`. See - /// https://developer.android.com/reference/android/graphics/ImageFormat#FLEX_RGBA_8888 + /// On Android, this is `android.graphics.PixelFormat.RGBA_8888`. See + /// https://developer.android.com/reference/android/graphics/PixelFormat#RGBA_8888 /// /// On iOS, this is `kCVPixelFormatType_32RGBA`. See /// https://developer.apple.com/documentation/corevideo/kcvpixelformattype_32rgba From d9eb45f92f427a29fc839f60f892002c12a7fb1f Mon Sep 17 00:00:00 2001 From: Mairramer Date: Fri, 1 May 2026 16:23:30 -0300 Subject: [PATCH 3/4] some fixes --- packages/camera/camera/pubspec.yaml | 6 ++++++ .../camera_android_camerax/example/lib/camera_image.dart | 6 ++++++ packages/camera/camera_android_camerax/example/pubspec.yaml | 2 +- packages/camera/camera_avfoundation/example/pubspec.yaml | 4 ++++ packages/camera/camera_avfoundation/pubspec.yaml | 2 +- .../lib/src/method_channel/type_conversion.dart | 2 +- 6 files changed, 19 insertions(+), 3 deletions(-) diff --git a/packages/camera/camera/pubspec.yaml b/packages/camera/camera/pubspec.yaml index f352a8f7d2f9..de32274a004e 100644 --- a/packages/camera/camera/pubspec.yaml +++ b/packages/camera/camera/pubspec.yaml @@ -38,3 +38,9 @@ dev_dependencies: topics: - camera +# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. +# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins +dependency_overrides: + camera_platform_interface: {path: ../camera_platform_interface} + camera_avfoundation: {path: ../camera_avfoundation} + camera_android_camerax: {path: ../camera_android_camerax} diff --git a/packages/camera/camera_android_camerax/example/lib/camera_image.dart b/packages/camera/camera_android_camerax/example/lib/camera_image.dart index ff7de7a735b6..80cd4ecb1e9b 100644 --- a/packages/camera/camera_android_camerax/example/lib/camera_image.dart +++ b/packages/camera/camera_android_camerax/example/lib/camera_image.dart @@ -89,6 +89,9 @@ ImageFormatGroup _asImageFormatGroup(dynamic rawFormat) { // android.graphics.ImageFormat.JPEG case 256: return ImageFormatGroup.jpeg; + // android.graphics.PixelFormat.RGBA_8888 + case 1: + return ImageFormatGroup.rgba8888; } } @@ -100,6 +103,9 @@ ImageFormatGroup _asImageFormatGroup(dynamic rawFormat) { // kCVPixelFormatType_32BGRA case 1111970369: return ImageFormatGroup.bgra8888; + // kCVPixelFormatType_32RGBA + case 1380401729: + return ImageFormatGroup.rgba8888; } } diff --git a/packages/camera/camera_android_camerax/example/pubspec.yaml b/packages/camera/camera_android_camerax/example/pubspec.yaml index 2f59cb505d84..c61580cd908e 100644 --- a/packages/camera/camera_android_camerax/example/pubspec.yaml +++ b/packages/camera/camera_android_camerax/example/pubspec.yaml @@ -31,5 +31,5 @@ flutter: # FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. # See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins dependency_overrides: - camera_platform_interface: {path: ../../../../packages/camera/camera_platform_interface} + camera_platform_interface: {path: ../../camera_platform_interface} diff --git a/packages/camera/camera_avfoundation/example/pubspec.yaml b/packages/camera/camera_avfoundation/example/pubspec.yaml index 4b9a5b5a5e53..06569a98b0ae 100644 --- a/packages/camera/camera_avfoundation/example/pubspec.yaml +++ b/packages/camera/camera_avfoundation/example/pubspec.yaml @@ -29,3 +29,7 @@ dev_dependencies: flutter: uses-material-design: true +# FOR TESTING AND INITIAL REVIEW ONLY. DO NOT MERGE. +# See https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins +dependency_overrides: + camera_platform_interface: {path: ../../camera_platform_interface} \ No newline at end of file diff --git a/packages/camera/camera_avfoundation/pubspec.yaml b/packages/camera/camera_avfoundation/pubspec.yaml index 1ccc1ccafaee..40864c378c7a 100644 --- a/packages/camera/camera_avfoundation/pubspec.yaml +++ b/packages/camera/camera_avfoundation/pubspec.yaml @@ -17,7 +17,7 @@ flutter: dartPluginClass: AVFoundationCamera dependencies: - camera_platform_interface: ^2.12.0 + camera_platform_interface: ^2.14.0 flutter: sdk: flutter stream_transform: ^2.0.0 diff --git a/packages/camera/camera_platform_interface/lib/src/method_channel/type_conversion.dart b/packages/camera/camera_platform_interface/lib/src/method_channel/type_conversion.dart index 44eed0580b6a..a402986ffd2c 100644 --- a/packages/camera/camera_platform_interface/lib/src/method_channel/type_conversion.dart +++ b/packages/camera/camera_platform_interface/lib/src/method_channel/type_conversion.dart @@ -37,7 +37,7 @@ ImageFormatGroup _imageFormatGroupFromPlatformData(dynamic data) { return ImageFormatGroup.yuv420; case 256: // android.graphics.ImageFormat.JPEG return ImageFormatGroup.jpeg; - case 42: // android.graphics.PixelFormat.RGBA_8888 + case 1: // android.graphics.PixelFormat.RGBA_8888 return ImageFormatGroup.rgba8888; } } From 30066ed021959cf89d9abeda18fd6cb997102d96 Mon Sep 17 00:00:00 2001 From: Mairramer Date: Fri, 1 May 2026 16:29:13 -0300 Subject: [PATCH 4/4] fix --- packages/camera/camera/lib/src/camera_image.dart | 4 ++-- .../lib/src/android_camera_camerax.dart | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/camera/camera/lib/src/camera_image.dart b/packages/camera/camera/lib/src/camera_image.dart index 76f3f86a6bf9..b3820fc1f627 100644 --- a/packages/camera/camera/lib/src/camera_image.dart +++ b/packages/camera/camera/lib/src/camera_image.dart @@ -89,8 +89,8 @@ ImageFormatGroup _asImageFormatGroup(dynamic rawFormat) { // android.graphics.ImageFormat.NV21 case 17: return ImageFormatGroup.nv21; - // android.graphics.ImageFormat.FLEX_RGBA_8888 - case 42: + // android.graphics.PixelFormat.RGBA_8888 + case 1: return ImageFormatGroup.rgba8888; } } diff --git a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart index b5552a900379..4e67ccbc878d 100644 --- a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart +++ b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart @@ -200,7 +200,7 @@ class AndroidCameraCameraX extends CameraPlatform { /// See https://developer.android.com/reference/androidx/camera/core/ImageAnalysis#OUTPUT_IMAGE_FORMAT_NV21(). static const int imageAnalysisOutputImageFormatNv21 = 3; - /// Constant representing the RGBA 8888 image format used for configuring ImageAnalysis. + /// Constant representing the RGBA_8888 image format used for configuring ImageAnalysis. /// /// See https://developer.android.com/reference/androidx/camera/core/ImageAnalysis#OUTPUT_IMAGE_FORMAT_RGBA_8888() static const int imageAnalysisOutputImageFormatRgba8888 = 2;