Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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_avfoundation/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.9.21+3

* Removes code for versions of iOS older than 13.0.
* Updates minimum supported SDK version to Flutter 3.35.

## 0.9.21+2

* Migrates `DefaultCamera` initialization to Swift.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ void main() {
testWidgets('Capture specific image resolutions', (
WidgetTester tester,
) async {
final List<CameraDescription> cameras =
await CameraPlatform.instance.availableCameras();
final List<CameraDescription> cameras = await CameraPlatform.instance
.availableCameras();
if (cameras.isEmpty) {
return;
}
Expand Down Expand Up @@ -138,8 +138,8 @@ void main() {
testWidgets('Capture specific video resolutions', (
WidgetTester tester,
) async {
final List<CameraDescription> cameras =
await CameraPlatform.instance.availableCameras();
final List<CameraDescription> cameras = await CameraPlatform.instance
.availableCameras();
if (cameras.isEmpty) {
return;
}
Expand Down Expand Up @@ -168,8 +168,8 @@ void main() {
});

testWidgets('Pause and resume video recording', (WidgetTester tester) async {
final List<CameraDescription> cameras =
await CameraPlatform.instance.availableCameras();
final List<CameraDescription> cameras = await CameraPlatform.instance
.availableCameras();
if (cameras.isEmpty) {
return;
}
Expand Down Expand Up @@ -222,8 +222,8 @@ void main() {
});

testWidgets('Set description while recording', (WidgetTester tester) async {
final List<CameraDescription> cameras =
await CameraPlatform.instance.availableCameras();
final List<CameraDescription> cameras = await CameraPlatform.instance
.availableCameras();
if (cameras.length < 2) {
return;
}
Expand All @@ -244,8 +244,8 @@ void main() {
});

testWidgets('Set description', (WidgetTester tester) async {
final List<CameraDescription> cameras =
await CameraPlatform.instance.availableCameras();
final List<CameraDescription> cameras = await CameraPlatform.instance
.availableCameras();
if (cameras.length < 2) {
return;
}
Expand Down Expand Up @@ -293,8 +293,8 @@ void main() {
testWidgets('image streaming with imageFormatGroup', (
WidgetTester tester,
) async {
final List<CameraDescription> cameras =
await CameraPlatform.instance.availableCameras();
final List<CameraDescription> cameras = await CameraPlatform.instance
.availableCameras();
if (cameras.isEmpty) {
return;
}
Expand All @@ -316,8 +316,8 @@ void main() {
});

testWidgets('Recording with video streaming', (WidgetTester tester) async {
final List<CameraDescription> cameras =
await CameraPlatform.instance.availableCameras();
final List<CameraDescription> cameras = await CameraPlatform.instance
.availableCameras();
if (cameras.isEmpty) {
return;
}
Expand Down Expand Up @@ -349,8 +349,8 @@ void main() {
testWidgets('Capture specific image output formats', (
WidgetTester tester,
) async {
final List<CameraDescription> cameras =
await CameraPlatform.instance.availableCameras();
final List<CameraDescription> cameras = await CameraPlatform.instance
.availableCameras();
if (cameras.isEmpty) {
return;
}
Expand All @@ -371,8 +371,8 @@ void main() {

group('Camera settings', () {
testWidgets('Control FPS', (WidgetTester tester) async {
final List<CameraDescription> cameras =
await CameraPlatform.instance.availableCameras();
final List<CameraDescription> cameras = await CameraPlatform.instance
.availableCameras();
if (cameras.isEmpty) {
return;
}
Expand Down Expand Up @@ -412,8 +412,8 @@ void main() {
});

testWidgets('Control video bitrate', (WidgetTester tester) async {
final List<CameraDescription> cameras =
await CameraPlatform.instance.availableCameras();
final List<CameraDescription> cameras = await CameraPlatform.instance
.availableCameras();
if (cameras.isEmpty) {
return;
}
Expand Down Expand Up @@ -454,8 +454,8 @@ void main() {
});

testWidgets('Control audio bitrate', (WidgetTester tester) async {
final List<CameraDescription> cameras =
await CameraPlatform.instance.availableCameras();
final List<CameraDescription> cameras = await CameraPlatform.instance
.availableCameras();
if (cameras.isEmpty) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
<string>arm64</string>
</array>
<key>MinimumOSVersion</key>
<string>12.0</string>
<string>13.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion packages/camera/camera_avfoundation/example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '12.0'
# platform :ios, '13.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@
CODE_SIGN_STYLE = Automatic;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = RunnerTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -676,7 +676,7 @@
CODE_SIGN_STYLE = Automatic;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = RunnerTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -740,7 +740,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -790,7 +790,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,9 @@ final class AvailableCamerasTest: XCTestCase {
telephotoCamera.position = .back

var requiredTypes: [AVCaptureDevice.DeviceType] = [
.builtInWideAngleCamera, .builtInTelephotoCamera,
.builtInWideAngleCamera, .builtInTelephotoCamera, .builtInUltraWideCamera,
]
if #available(iOS 13.0, *) {
requiredTypes.append(.builtInUltraWideCamera)
}
var cameras = [wideAngleCamera, frontFacingCamera, telephotoCamera]
if #available(iOS 13.0, *) {
cameras.append(ultraWideCamera)
}
var cameras = [wideAngleCamera, frontFacingCamera, telephotoCamera, ultraWideCamera]

XCTAssertEqual(deviceTypes, requiredTypes)
XCTAssertEqual(mediaType, .video)
Expand All @@ -77,11 +71,7 @@ final class AvailableCamerasTest: XCTestCase {
waitForExpectations(timeout: 30, handler: nil)

// Verify the result.
if #available(iOS 13.0, *) {
XCTAssertEqual(resultValue?.count, 4)
} else {
XCTAssertEqual(resultValue?.count, 3)
}
XCTAssertEqual(resultValue?.count, 4)
}

func testAvailableCamerasShouldReturnTwoCamerasOnDualCameraIPhone() {
Expand All @@ -100,11 +90,8 @@ final class AvailableCamerasTest: XCTestCase {
frontFacingCamera.position = .front

var requiredTypes: [AVCaptureDevice.DeviceType] = [
.builtInWideAngleCamera, .builtInTelephotoCamera,
.builtInWideAngleCamera, .builtInTelephotoCamera, .builtInUltraWideCamera,
]
if #available(iOS 13.0, *) {
requiredTypes.append(.builtInUltraWideCamera)
}
let cameras = [wideAngleCamera, frontFacingCamera]

XCTAssertEqual(deviceTypes, requiredTypes)
Expand Down Expand Up @@ -136,11 +123,8 @@ final class AvailableCamerasTest: XCTestCase {
unspecifiedCamera.position = .unspecified

var requiredTypes: [AVCaptureDevice.DeviceType] = [
.builtInWideAngleCamera, .builtInTelephotoCamera,
.builtInWideAngleCamera, .builtInTelephotoCamera, .builtInUltraWideCamera,
]
if #available(iOS 13.0, *) {
requiredTypes.append(.builtInUltraWideCamera)
}
let cameras = [unspecifiedCamera]

XCTAssertEqual(deviceTypes, requiredTypes)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,17 @@ class CameraValue {
exposureMode: exposureMode ?? this.exposureMode,
focusMode: focusMode ?? this.focusMode,
deviceOrientation: deviceOrientation ?? this.deviceOrientation,
lockedCaptureOrientation:
lockedCaptureOrientation == null
? this.lockedCaptureOrientation
: lockedCaptureOrientation.orNull,
recordingOrientation:
recordingOrientation == null
? this.recordingOrientation
: recordingOrientation.orNull,
lockedCaptureOrientation: lockedCaptureOrientation == null
? this.lockedCaptureOrientation
: lockedCaptureOrientation.orNull,
recordingOrientation: recordingOrientation == null
? this.recordingOrientation
: recordingOrientation.orNull,
isPreviewPaused: isPreviewPaused ?? this.isPreviewPaused,
description: description ?? this.description,
previewPauseOrientation:
previewPauseOrientation == null
? this.previewPauseOrientation
: previewPauseOrientation.orNull,
previewPauseOrientation: previewPauseOrientation == null
? this.previewPauseOrientation
: previewPauseOrientation.orNull,
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,26 @@ class CameraPreview extends StatelessWidget {
Widget build(BuildContext context) {
return controller.value.isInitialized
? ValueListenableBuilder<CameraValue>(
valueListenable: controller,
builder: (BuildContext context, Object? value, Widget? child) {
final double cameraAspectRatio =
controller.value.previewSize!.width /
controller.value.previewSize!.height;
return AspectRatio(
aspectRatio:
_isLandscape() ? cameraAspectRatio : (1 / cameraAspectRatio),
child: Stack(
fit: StackFit.expand,
children: <Widget>[
_wrapInRotatedBox(child: controller.buildPreview()),
child ?? Container(),
],
),
);
},
child: child,
)
valueListenable: controller,
builder: (BuildContext context, Object? value, Widget? child) {
final double cameraAspectRatio =
controller.value.previewSize!.width /
controller.value.previewSize!.height;
return AspectRatio(
aspectRatio: _isLandscape()
? cameraAspectRatio
: (1 / cameraAspectRatio),
child: Stack(
fit: StackFit.expand,
children: <Widget>[
_wrapInRotatedBox(child: controller.buildPreview()),
child ?? Container(),
],
),
);
},
child: child,
)
: Container();
}

Expand Down Expand Up @@ -74,7 +75,7 @@ class CameraPreview extends StatelessWidget {
return controller.value.isRecordingVideo
? controller.value.recordingOrientation!
: (controller.value.previewPauseOrientation ??
controller.value.lockedCaptureOrientation ??
controller.value.deviceOrientation);
controller.value.lockedCaptureOrientation ??
controller.value.deviceOrientation);
}
}
Loading