Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
dad18b9
add lens type info to camera plugin [ios-only]
lenzpaul Mar 6, 2025
a53858b
run pigeon generator
lenzpaul Mar 6, 2025
6b8fa07
Update tests
lenzpaul Mar 6, 2025
e0c743a
updated versions and Changelogs
lenzpaul Mar 6, 2025
78fbe47
adds dependency_overrides for federated plugin PR
lenzpaul Mar 6, 2025
2248a71
Add lens type information to camera plugin tests
lenzpaul Mar 6, 2025
0bbfd07
Add iOS version checks ensuring API availability for camera device types
lenzpaul Mar 6, 2025
5e347d7
Apply formatting fixes
lenzpaul Mar 6, 2025
989a270
created helper function for lens direction and type
lenzpaul Mar 6, 2025
ba8263a
Change lens type enum to only use UltraWide, Wide, and Telephoto
lenzpaul Mar 6, 2025
ae66e57
run pigeon gen and applied flutter_plugin_tools.dart formatting
lenzpaul Mar 6, 2025
ec472d7
Update CHANGELOG and Fix CI errors
lenzpaul Mar 6, 2025
9540ef7
Fix formatting for CI
lenzpaul Mar 6, 2025
5a3db31
Refactor camera lens direction and type handling in CameraPlugin
lenzpaul Mar 6, 2025
39aac3c
Fix documentation for camera lens type descriptions in messages.dart …
lenzpaul Mar 6, 2025
ec7f8f2
run format script
lenzpaul Mar 6, 2025
16f9fc4
Remove unnecessary pubspec changes
lenzpaul Mar 6, 2025
d2404a6
Remove temporary dependency overrides from pubspec.yaml files
lenzpaul Mar 6, 2025
697c023
Remove Runner changes
lenzpaul Mar 6, 2025
8aed9ea
Updates versions and CHANGELOGs. Runs pigeon generator
lenzpaul Mar 6, 2025
119beaa
Revert implementation changes in camera_avfoundation
lenzpaul Mar 6, 2025
e338f6f
Revert changes in camera pkg
lenzpaul Mar 6, 2025
93e2484
Updates CameraDescription tests to add toString and include lensType
lenzpaul Mar 7, 2025
77fe9da
Minor changelog adjustments
stuartmorgan-g Mar 7, 2025
8348878
Merge branch 'main' into camera_package_patch_2
stuartmorgan-g Mar 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/camera/camera_platform_interface/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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.
Expand All @@ -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)';
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should get a test as well. It looks like currently we don't have a toString test specifically for CameraDescription, which we should (only the indirect test in the wrong package that I'm about to change to not test this part any more).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

}
2 changes: 1 addition & 1 deletion packages/camera/camera_platform_interface/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,27 @@ 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', () {
const CameraDescription firstDescription = CameraDescription(
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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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)',
);
});
});
}