diff --git a/packages/camera/camera_platform_interface/CHANGELOG.md b/packages/camera/camera_platform_interface/CHANGELOG.md index d122ae154d0..d00f721a79b 100644 --- a/packages/camera/camera_platform_interface/CHANGELOG.md +++ b/packages/camera/camera_platform_interface/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.10.0 + +* Introduces a new `CameraLensType` enum to provide lens type information about + the camera (e.g., ultra-wide, telephoto, ...). + ## 2.9.0 * Updates minimum supported SDK version to Flutter 3.22/Dart 3.4. diff --git a/packages/camera/camera_platform_interface/lib/src/types/camera_description.dart b/packages/camera/camera_platform_interface/lib/src/types/camera_description.dart index 0167cf9e17a..4d5b3ec543f 100644 --- a/packages/camera/camera_platform_interface/lib/src/types/camera_description.dart +++ b/packages/camera/camera_platform_interface/lib/src/types/camera_description.dart @@ -16,6 +16,23 @@ enum CameraLensDirection { external, } +/// Represents various built-in camera lens types available on a device. +/// +/// Each lens type offers different focal lengths and capabilities for capturing images. +enum CameraLensType { + /// 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, +} + /// Properties of a camera device. @immutable class CameraDescription { @@ -24,6 +41,7 @@ class CameraDescription { required this.name, required this.lensDirection, required this.sensorOrientation, + this.lensType = CameraLensType.unknown, }); /// The name of the camera device. @@ -41,20 +59,24 @@ class CameraDescription { /// is from top to bottom in the sensor's coordinate system. final int sensorOrientation; + /// The type of lens the camera has. + final CameraLensType lensType; + @override bool operator ==(Object other) => identical(this, other) || other is CameraDescription && runtimeType == other.runtimeType && name == other.name && - lensDirection == other.lensDirection; + lensDirection == other.lensDirection && + lensType == other.lensType; @override - int get hashCode => Object.hash(name, lensDirection); + int get hashCode => Object.hash(name, lensDirection, lensType); @override String toString() { return '${objectRuntimeType(this, 'CameraDescription')}(' - '$name, $lensDirection, $sensorOrientation)'; + '$name, $lensDirection, $sensorOrientation, $lensType)'; } } diff --git a/packages/camera/camera_platform_interface/pubspec.yaml b/packages/camera/camera_platform_interface/pubspec.yaml index bea9eef2319..a26c038ed11 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.9.0 +version: 2.10.0 environment: sdk: ^3.4.0 diff --git a/packages/camera/camera_platform_interface/test/types/camera_description_test.dart b/packages/camera/camera_platform_interface/test/types/camera_description_test.dart index a86df031ac3..effd36951fc 100644 --- a/packages/camera/camera_platform_interface/test/types/camera_description_test.dart +++ b/packages/camera/camera_platform_interface/test/types/camera_description_test.dart @@ -30,11 +30,13 @@ void main() { name: 'Test', lensDirection: CameraLensDirection.front, sensorOrientation: 90, + lensType: CameraLensType.ultraWide, ); expect(description.name, 'Test'); expect(description.lensDirection, CameraLensDirection.front); expect(description.sensorOrientation, 90); + expect(description.lensType, CameraLensType.ultraWide); }); test('equals should return true if objects are the same', () { @@ -42,11 +44,13 @@ void main() { name: 'Test', lensDirection: CameraLensDirection.front, sensorOrientation: 90, + lensType: CameraLensType.ultraWide, ); const CameraDescription secondDescription = CameraDescription( name: 'Test', lensDirection: CameraLensDirection.front, sensorOrientation: 90, + lensType: CameraLensType.ultraWide, ); expect(firstDescription == secondDescription, true); @@ -57,11 +61,13 @@ void main() { name: 'Test', lensDirection: CameraLensDirection.front, sensorOrientation: 90, + lensType: CameraLensType.ultraWide, ); const CameraDescription secondDescription = CameraDescription( name: 'Testing', lensDirection: CameraLensDirection.front, sensorOrientation: 90, + lensType: CameraLensType.ultraWide, ); expect(firstDescription == secondDescription, false); @@ -72,11 +78,13 @@ void main() { name: 'Test', lensDirection: CameraLensDirection.front, sensorOrientation: 90, + lensType: CameraLensType.ultraWide, ); const CameraDescription secondDescription = CameraDescription( name: 'Test', lensDirection: CameraLensDirection.back, sensorOrientation: 90, + lensType: CameraLensType.ultraWide, ); expect(firstDescription == secondDescription, false); @@ -87,11 +95,13 @@ void main() { name: 'Test', lensDirection: CameraLensDirection.front, sensorOrientation: 0, + lensType: CameraLensType.ultraWide, ); const CameraDescription secondDescription = CameraDescription( name: 'Test', lensDirection: CameraLensDirection.front, sensorOrientation: 90, + lensType: CameraLensType.ultraWide, ); expect(firstDescription == secondDescription, true); @@ -103,11 +113,26 @@ void main() { name: 'Test', lensDirection: CameraLensDirection.front, sensorOrientation: 0, + lensType: CameraLensType.ultraWide, ); - final int expectedHashCode = - Object.hash(description.name, description.lensDirection); + final int expectedHashCode = Object.hash( + description.name, description.lensDirection, description.lensType); expect(description.hashCode, expectedHashCode); }); + + test('toString should return correct string representation', () { + const CameraDescription description = CameraDescription( + name: 'Test', + lensDirection: CameraLensDirection.front, + sensorOrientation: 90, + lensType: CameraLensType.ultraWide, + ); + + expect( + description.toString(), + 'CameraDescription(Test, CameraLensDirection.front, 90, CameraLensType.ultraWide)', + ); + }); }); }