[camera] NNBD migration of the camera plugin (#3533)
* Migrate camera_platform_interface to null safety
* Exclude camera_platform_interface from all plugins script
* Convert CameraId in test to non-nullable
* Migrate to nullsafety
* Attempt to fix dependency problem building all plugins
* Update version information
* Fix type
* Make exposureMode and focusMode non-nullable
* Mark google_maps_flutter as non-NNBD
* Update dependencies
* Added missing entry to CHANGELOG.md
* Rebased on master
diff --git a/packages/camera/camera/CHANGELOG.md b/packages/camera/camera/CHANGELOG.md
index e365e76..aee3774 100644
--- a/packages/camera/camera/CHANGELOG.md
+++ b/packages/camera/camera/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.8.0-nullsafety
+
+* Migrated to null safety.
+
## 0.7.0+4
* Fix crash when taking picture with orientation lock
diff --git a/packages/camera/camera/example/ios/Flutter/Debug.xcconfig b/packages/camera/camera/example/ios/Flutter/Debug.xcconfig
index e8efba1..b2f5fae 100644
--- a/packages/camera/camera/example/ios/Flutter/Debug.xcconfig
+++ b/packages/camera/camera/example/ios/Flutter/Debug.xcconfig
@@ -1,2 +1,3 @@
+#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
diff --git a/packages/camera/camera/example/ios/Flutter/Release.xcconfig b/packages/camera/camera/example/ios/Flutter/Release.xcconfig
index 399e934..88c2914 100644
--- a/packages/camera/camera/example/ios/Flutter/Release.xcconfig
+++ b/packages/camera/camera/example/ios/Flutter/Release.xcconfig
@@ -1,2 +1,3 @@
+#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
diff --git a/packages/camera/camera/example/ios/Runner.xcodeproj/project.pbxproj b/packages/camera/camera/example/ios/Runner.xcodeproj/project.pbxproj
index d51240a..3f71bb6 100644
--- a/packages/camera/camera/example/ios/Runner.xcodeproj/project.pbxproj
+++ b/packages/camera/camera/example/ios/Runner.xcodeproj/project.pbxproj
@@ -147,7 +147,6 @@
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
- FE224661708E6DA2A0F8B952 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
@@ -252,24 +251,6 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
- FE224661708E6DA2A0F8B952 /* [CP] Embed Pods Frameworks */ = {
- isa = PBXShellScriptBuildPhase;
- buildActionMask = 2147483647;
- files = (
- );
- inputPaths = (
- "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
- "${PODS_ROOT}/../Flutter/Flutter.framework",
- );
- name = "[CP] Embed Pods Frameworks";
- outputPaths = (
- "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
- );
- runOnlyForDeploymentPostprocessing = 0;
- shellPath = /bin/sh;
- shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
- showEnvVarsInLog = 0;
- };
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
diff --git a/packages/camera/camera/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/packages/camera/camera/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata
index 1d526a1..919434a 100644
--- a/packages/camera/camera/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata
+++ b/packages/camera/camera/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -2,6 +2,6 @@
<Workspace
version = "1.0">
<FileRef
- location = "group:Runner.xcodeproj">
+ location = "self:">
</FileRef>
</Workspace>
diff --git a/packages/camera/camera/lib/src/camera_controller.dart b/packages/camera/camera/lib/src/camera_controller.dart
index 80e83c8..bb976d1 100644
--- a/packages/camera/camera/lib/src/camera_controller.dart
+++ b/packages/camera/camera/lib/src/camera_controller.dart
@@ -32,19 +32,19 @@
class CameraValue {
/// Creates a new camera controller state.
const CameraValue({
- this.isInitialized,
+ required this.isInitialized,
this.errorDescription,
this.previewSize,
- this.isRecordingVideo,
- this.isTakingPicture,
- this.isStreamingImages,
- bool isRecordingPaused,
- this.flashMode,
- this.exposureMode,
- this.focusMode,
- this.exposurePointSupported,
- this.focusPointSupported,
- this.deviceOrientation,
+ required this.isRecordingVideo,
+ required this.isTakingPicture,
+ required this.isStreamingImages,
+ required bool isRecordingPaused,
+ required this.flashMode,
+ required this.exposureMode,
+ required this.focusMode,
+ required this.exposurePointSupported,
+ required this.focusPointSupported,
+ required this.deviceOrientation,
this.lockedCaptureOrientation,
this.recordingOrientation,
}) : _isRecordingPaused = isRecordingPaused;
@@ -58,7 +58,9 @@
isStreamingImages: false,
isRecordingPaused: false,
flashMode: FlashMode.auto,
+ exposureMode: ExposureMode.auto,
exposurePointSupported: false,
+ focusMode: FocusMode.auto,
focusPointSupported: false,
deviceOrientation: DeviceOrientation.portraitUp,
);
@@ -84,17 +86,17 @@
///
/// This is null while the controller is not in an error state.
/// When [hasError] is true this contains the error description.
- final String errorDescription;
+ final String? errorDescription;
/// The size of the preview in pixels.
///
- /// Is `null` until [isInitialized] is `true`.
- final Size previewSize;
+ /// Is `null` until [isInitialized] is `true`.
+ final Size? previewSize;
/// Convenience getter for `previewSize.width / previewSize.height`.
///
/// Can only be called when [initialize] is done.
- double get aspectRatio => previewSize.width / previewSize.height;
+ double get aspectRatio => previewSize!.width / previewSize!.height;
/// Whether the controller is in an error state.
///
@@ -120,34 +122,34 @@
final DeviceOrientation deviceOrientation;
/// The currently locked capture orientation.
- final DeviceOrientation lockedCaptureOrientation;
+ final DeviceOrientation? lockedCaptureOrientation;
/// Whether the capture orientation is currently locked.
bool get isCaptureOrientationLocked => lockedCaptureOrientation != null;
/// The orientation of the currently running video recording.
- final DeviceOrientation recordingOrientation;
+ final DeviceOrientation? recordingOrientation;
/// Creates a modified copy of the object.
///
/// Explicitly specified fields get the specified value, all other fields get
/// the same value of the current object.
CameraValue copyWith({
- bool isInitialized,
- bool isRecordingVideo,
- bool isTakingPicture,
- bool isStreamingImages,
- String errorDescription,
- Size previewSize,
- bool isRecordingPaused,
- FlashMode flashMode,
- ExposureMode exposureMode,
- FocusMode focusMode,
- bool exposurePointSupported,
- bool focusPointSupported,
- DeviceOrientation deviceOrientation,
- Optional<DeviceOrientation> lockedCaptureOrientation,
- Optional<DeviceOrientation> recordingOrientation,
+ bool? isInitialized,
+ bool? isRecordingVideo,
+ bool? isTakingPicture,
+ bool? isStreamingImages,
+ String? errorDescription,
+ Size? previewSize,
+ bool? isRecordingPaused,
+ FlashMode? flashMode,
+ ExposureMode? exposureMode,
+ FocusMode? focusMode,
+ bool? exposurePointSupported,
+ bool? focusPointSupported,
+ DeviceOrientation? deviceOrientation,
+ Optional<DeviceOrientation>? lockedCaptureOrientation,
+ Optional<DeviceOrientation>? recordingOrientation,
}) {
return CameraValue(
isInitialized: isInitialized ?? this.isInitialized,
@@ -225,13 +227,17 @@
/// The [ImageFormatGroup] describes the output of the raw image format.
///
/// When null the imageFormat will fallback to the platforms default.
- final ImageFormatGroup imageFormatGroup;
+ final ImageFormatGroup? imageFormatGroup;
- int _cameraId;
+ /// The id of a camera that hasn't been initialized.
+ @visibleForTesting
+ static const int kUninitializedCameraId = -1;
+ int _cameraId = kUninitializedCameraId;
+
bool _isDisposed = false;
- StreamSubscription<dynamic> _imageStreamSubscription;
- FutureOr<bool> _initCalled;
- StreamSubscription _deviceOrientationSubscription;
+ StreamSubscription<dynamic>? _imageStreamSubscription;
+ FutureOr<bool>? _initCalled;
+ StreamSubscription? _deviceOrientationSubscription;
/// Checks whether [CameraController.dispose] has completed successfully.
///
@@ -278,7 +284,7 @@
await CameraPlatform.instance.initializeCamera(
_cameraId,
- imageFormatGroup: imageFormatGroup,
+ imageFormatGroup: imageFormatGroup ?? ImageFormatGroup.unknown,
);
value = value.copyWith(
@@ -422,7 +428,7 @@
throw CameraException(e.code, e.message);
}
- await _imageStreamSubscription.cancel();
+ await _imageStreamSubscription?.cancel();
_imageStreamSubscription = null;
}
@@ -583,12 +589,16 @@
}
/// Sets the exposure point for automatically determining the exposure value.
- Future<void> setExposurePoint(Offset point) async {
+ ///
+ /// Supplying a `null` value will reset the exposure point to it's default
+ /// value.
+ Future<void> setExposurePoint(Offset? point) async {
if (point != null &&
(point.dx < 0 || point.dx > 1 || point.dy < 0 || point.dy > 1)) {
throw ArgumentError(
'The values of point should be anywhere between (0,0) and (1,1).');
}
+
try {
await CameraPlatform.instance.setExposurePoint(
_cameraId,
@@ -682,7 +692,7 @@
/// Locks the capture orientation.
///
/// If [orientation] is omitted, the current device orientation is used.
- Future<void> lockCaptureOrientation([DeviceOrientation orientation]) async {
+ Future<void> lockCaptureOrientation([DeviceOrientation? orientation]) async {
try {
await CameraPlatform.instance.lockCaptureOrientation(
_cameraId, orientation ?? value.deviceOrientation);
@@ -715,7 +725,10 @@
}
/// Sets the focus point for automatically determining the focus value.
- Future<void> setFocusPoint(Offset point) async {
+ ///
+ /// Supplying a `null` value will reset the focus point to it's default
+ /// value.
+ Future<void> setFocusPoint(Offset? point) async {
if (point != null &&
(point.dx < 0 || point.dx > 1 || point.dy < 0 || point.dy > 1)) {
throw ArgumentError(
diff --git a/packages/camera/camera/lib/src/camera_image.dart b/packages/camera/camera/lib/src/camera_image.dart
index dffa506..46aa2a6 100644
--- a/packages/camera/camera/lib/src/camera_image.dart
+++ b/packages/camera/camera/lib/src/camera_image.dart
@@ -26,7 +26,7 @@
/// The distance between adjacent pixel samples on Android, in bytes.
///
/// Will be `null` on iOS.
- final int bytesPerPixel;
+ final int? bytesPerPixel;
/// The row stride for this color plane, in bytes.
final int bytesPerRow;
@@ -34,12 +34,12 @@
/// Height of the pixel buffer on iOS.
///
/// Will be `null` on Android
- final int height;
+ final int? height;
/// Width of the pixel buffer on iOS.
///
/// Will be `null` on Android.
- final int width;
+ final int? width;
}
/// Describes how pixels are represented in an image.
diff --git a/packages/camera/camera/lib/src/camera_preview.dart b/packages/camera/camera/lib/src/camera_preview.dart
index 05e9690..f6d357b 100644
--- a/packages/camera/camera/lib/src/camera_preview.dart
+++ b/packages/camera/camera/lib/src/camera_preview.dart
@@ -17,7 +17,7 @@
final CameraController controller;
/// A widget to overlay on top of the camera preview
- final Widget child;
+ final Widget? child;
@override
Widget build(BuildContext context) {
@@ -43,7 +43,7 @@
DeviceOrientation _getApplicableOrientation() {
return controller.value.isRecordingVideo
- ? controller.value.recordingOrientation
+ ? controller.value.recordingOrientation!
: (controller.value.lockedCaptureOrientation ??
controller.value.deviceOrientation);
}
@@ -61,6 +61,6 @@
DeviceOrientation.portraitDown: 2,
DeviceOrientation.landscapeRight: 3,
};
- return turns[_getApplicableOrientation()] + platformOffset;
+ return turns[_getApplicableOrientation()]! + platformOffset;
}
}
diff --git a/packages/camera/camera/pubspec.yaml b/packages/camera/camera/pubspec.yaml
index 5ac4b57..7ed08d8 100644
--- a/packages/camera/camera/pubspec.yaml
+++ b/packages/camera/camera/pubspec.yaml
@@ -2,25 +2,26 @@
description: A Flutter plugin for getting information about and controlling the
camera on Android and iOS. Supports previewing the camera feed, capturing images, capturing video,
and streaming image buffers to dart.
-version: 0.7.0+4
+version: 0.8.0-nullsafety
homepage: https://github.com/flutter/plugins/tree/master/packages/camera/camera
dependencies:
flutter:
sdk: flutter
- camera_platform_interface: ^1.5.0
- pedantic: ^1.8.0
- quiver: ^2.1.5
+
+ camera_platform_interface: ^2.0.0-nullsafety
+
+ pedantic: ^1.10.0
+ quiver: ^3.0.0-nullsafety.3
dev_dependencies:
- path_provider: ^0.5.0
- video_player: ^0.10.0
+ video_player: ^2.0.0-nullsafety.7
flutter_test:
sdk: flutter
flutter_driver:
sdk: flutter
- mockito: ^4.1.3
- plugin_platform_interface: ^1.0.3
+ mockito: ^5.0.0-nullsafety.5
+ plugin_platform_interface: ^1.1.0-nullsafety.2
flutter:
plugin:
@@ -32,5 +33,5 @@
pluginClass: CameraPlugin
environment:
- sdk: ">=2.7.0 <3.0.0"
- flutter: ">=1.12.13+hotfix.5"
+ sdk: '>=2.12.0-0 <3.0.0'
+ flutter: ">=1.22.0"
diff --git a/packages/camera/camera/test/camera_test.dart b/packages/camera/camera/test/camera_test.dart
index d0b09fa..b37b770 100644
--- a/packages/camera/camera/test/camera_test.dart
+++ b/packages/camera/camera/test/camera_test.dart
@@ -426,10 +426,10 @@
await cameraController.initialize();
when(CameraPlatform.instance.getMaxZoomLevel(mockInitializeCamera))
- .thenThrow(PlatformException(
- code: 'TEST_ERROR',
- message: 'This is a test error messge',
- details: null));
+ .thenThrow(CameraException(
+ 'TEST_ERROR',
+ 'This is a test error messge',
+ ));
expect(
cameraController.getMaxZoomLevel,
@@ -526,10 +526,10 @@
await cameraController.initialize();
when(CameraPlatform.instance.getMinZoomLevel(mockInitializeCamera))
- .thenThrow(PlatformException(
- code: 'TEST_ERROR',
- message: 'This is a test error messge',
- details: null));
+ .thenThrow(CameraException(
+ 'TEST_ERROR',
+ 'This is a test error messge',
+ ));
expect(
cameraController.getMinZoomLevel,
@@ -625,10 +625,10 @@
await cameraController.initialize();
when(CameraPlatform.instance.setZoomLevel(mockInitializeCamera, 42.0))
- .thenThrow(PlatformException(
- code: 'TEST_ERROR',
- message: 'This is a test error messge',
- details: null));
+ .thenThrow(CameraException(
+ 'TEST_ERROR',
+ 'This is a test error messge',
+ ));
expect(
() => cameraController.setZoomLevel(42),
@@ -804,6 +804,10 @@
ResolutionPreset.max);
await cameraController.initialize();
+ when(CameraPlatform.instance
+ .getMinExposureOffset(cameraController.cameraId))
+ .thenAnswer((_) => Future.value(0.0));
+
await cameraController.getMinExposureOffset();
verify(CameraPlatform.instance
@@ -824,10 +828,9 @@
when(CameraPlatform.instance
.getMinExposureOffset(cameraController.cameraId))
.thenThrow(
- PlatformException(
- code: 'TEST_ERROR',
- message: 'This is a test error message',
- details: null,
+ CameraException(
+ 'TEST_ERROR',
+ 'This is a test error message',
),
);
@@ -849,6 +852,10 @@
ResolutionPreset.max);
await cameraController.initialize();
+ when(CameraPlatform.instance
+ .getMaxExposureOffset(cameraController.cameraId))
+ .thenAnswer((_) => Future.value(1.0));
+
await cameraController.getMaxExposureOffset();
verify(CameraPlatform.instance
@@ -869,10 +876,9 @@
when(CameraPlatform.instance
.getMaxExposureOffset(cameraController.cameraId))
.thenThrow(
- PlatformException(
- code: 'TEST_ERROR',
- message: 'This is a test error message',
- details: null,
+ CameraException(
+ 'TEST_ERROR',
+ 'This is a test error message',
),
);
@@ -894,10 +900,14 @@
ResolutionPreset.max);
await cameraController.initialize();
+ when(CameraPlatform.instance
+ .getExposureOffsetStepSize(cameraController.cameraId))
+ .thenAnswer((_) => Future.value(0.0));
+
await cameraController.getExposureOffsetStepSize();
verify(CameraPlatform.instance
- .getMinExposureOffset(cameraController.cameraId))
+ .getExposureOffsetStepSize(cameraController.cameraId))
.called(1);
});
@@ -915,10 +925,9 @@
when(CameraPlatform.instance
.getExposureOffsetStepSize(cameraController.cameraId))
.thenThrow(
- PlatformException(
- code: 'TEST_ERROR',
- message: 'This is a test error message',
- details: null,
+ CameraException(
+ 'TEST_ERROR',
+ 'This is a test error message',
),
);
@@ -948,6 +957,9 @@
when(CameraPlatform.instance
.getExposureOffsetStepSize(cameraController.cameraId))
.thenAnswer((_) async => 1.0);
+ when(CameraPlatform.instance
+ .setExposureOffset(cameraController.cameraId, 1.0))
+ .thenAnswer((_) async => 1.0);
await cameraController.setExposureOffset(1.0);
@@ -977,10 +989,9 @@
when(CameraPlatform.instance
.setExposureOffset(cameraController.cameraId, 1.0))
.thenThrow(
- PlatformException(
- code: 'TEST_ERROR',
- message: 'This is a test error message',
- details: null,
+ CameraException(
+ 'TEST_ERROR',
+ 'This is a test error message',
),
);
@@ -1012,6 +1023,15 @@
when(CameraPlatform.instance
.getExposureOffsetStepSize(cameraController.cameraId))
.thenAnswer((_) async => 1.0);
+ when(CameraPlatform.instance
+ .setExposureOffset(cameraController.cameraId, 0.0))
+ .thenAnswer((_) async => 0.0);
+ when(CameraPlatform.instance
+ .setExposureOffset(cameraController.cameraId, -1.0))
+ .thenAnswer((_) async => 0.0);
+ when(CameraPlatform.instance
+ .setExposureOffset(cameraController.cameraId, 2.0))
+ .thenAnswer((_) async => 0.0);
expect(
cameraController.setExposureOffset(3.0),
@@ -1028,17 +1048,18 @@
'The provided exposure offset was outside the supported range for this device.',
)));
- await cameraController.setExposureOffset(2.0);
+ await cameraController.setExposureOffset(0.0);
await cameraController.setExposureOffset(-1.0);
- await cameraController.setExposureOffset(-0.0);
+ await cameraController.setExposureOffset(2.0);
+
verify(CameraPlatform.instance
- .setExposureOffset(cameraController.cameraId, 2.0))
+ .setExposureOffset(cameraController.cameraId, 0.0))
.called(1);
verify(CameraPlatform.instance
.setExposureOffset(cameraController.cameraId, -1.0))
.called(1);
verify(CameraPlatform.instance
- .setExposureOffset(cameraController.cameraId, 0.0))
+ .setExposureOffset(cameraController.cameraId, 2.0))
.called(1);
});
@@ -1052,19 +1073,38 @@
await cameraController.initialize();
when(CameraPlatform.instance
.getMinExposureOffset(cameraController.cameraId))
- .thenAnswer((_) async => -1.0);
+ .thenAnswer((_) async => -1.2);
when(CameraPlatform.instance
.getMaxExposureOffset(cameraController.cameraId))
- .thenAnswer((_) async => 1.0);
+ .thenAnswer((_) async => 1.2);
when(CameraPlatform.instance
.getExposureOffsetStepSize(cameraController.cameraId))
.thenAnswer((_) async => 0.4);
- when(CameraPlatform.instance
- .setExposureOffset(cameraController.cameraId, 1.0))
- .thenAnswer((_) async => 1.0);
- await cameraController.setExposureOffset(1.0);
- await cameraController.setExposureOffset(-1.0);
+ when(CameraPlatform.instance
+ .setExposureOffset(cameraController.cameraId, -1.2))
+ .thenAnswer((_) async => -1.2);
+ when(CameraPlatform.instance
+ .setExposureOffset(cameraController.cameraId, -0.8))
+ .thenAnswer((_) async => -0.8);
+ when(CameraPlatform.instance
+ .setExposureOffset(cameraController.cameraId, -0.4))
+ .thenAnswer((_) async => -0.4);
+ when(CameraPlatform.instance
+ .setExposureOffset(cameraController.cameraId, 0.0))
+ .thenAnswer((_) async => 0.0);
+ when(CameraPlatform.instance
+ .setExposureOffset(cameraController.cameraId, 0.4))
+ .thenAnswer((_) async => 0.4);
+ when(CameraPlatform.instance
+ .setExposureOffset(cameraController.cameraId, 0.8))
+ .thenAnswer((_) async => 0.8);
+ when(CameraPlatform.instance
+ .setExposureOffset(cameraController.cameraId, 1.2))
+ .thenAnswer((_) async => 1.2);
+
+ await cameraController.setExposureOffset(1.2);
+ await cameraController.setExposureOffset(-1.2);
await cameraController.setExposureOffset(0.1);
await cameraController.setExposureOffset(0.2);
await cameraController.setExposureOffset(0.3);
@@ -1082,10 +1122,10 @@
verify(CameraPlatform.instance
.setExposureOffset(cameraController.cameraId, 0.8))
- .called(3);
+ .called(2);
verify(CameraPlatform.instance
.setExposureOffset(cameraController.cameraId, -0.8))
- .called(3);
+ .called(2);
verify(CameraPlatform.instance
.setExposureOffset(cameraController.cameraId, 0.0))
.called(2);
@@ -1203,8 +1243,22 @@
with MockPlatformInterfaceMixin
implements CameraPlatform {
@override
- Future<void> initializeCamera(int cameraId,
- {ImageFormatGroup imageFormatGroup});
+ Future<void> initializeCamera(
+ int? cameraId, {
+ ImageFormatGroup? imageFormatGroup = ImageFormatGroup.unknown,
+ }) async =>
+ super.noSuchMethod(Invocation.method(
+ #initializeCamera,
+ [cameraId],
+ {
+ #imageFormatGroup: imageFormatGroup,
+ },
+ ));
+
+ @override
+ Future<void> dispose(int? cameraId) async {
+ return super.noSuchMethod(Invocation.method(#dispose, [cameraId]));
+ }
@override
Future<List<CameraDescription>> availableCameras() =>
@@ -1213,8 +1267,8 @@
@override
Future<int> createCamera(
CameraDescription description,
- ResolutionPreset resolutionPreset, {
- bool enableAudio,
+ ResolutionPreset? resolutionPreset, {
+ bool enableAudio = true,
}) =>
mockPlatformException
? throw PlatformException(code: 'foo', message: 'bar')
@@ -1242,12 +1296,91 @@
: Future.value(mockTakePicture);
@override
+ Future<void> prepareForVideoRecording() async =>
+ super.noSuchMethod(Invocation.method(#prepareForVideoRecording, null));
+
+ @override
Future<XFile> startVideoRecording(int cameraId,
- {Duration maxVideoDuration}) =>
+ {Duration? maxVideoDuration}) =>
Future.value(mockVideoRecordingXFile);
+
+ @override
+ Future<void> lockCaptureOrientation(
+ int? cameraId, DeviceOrientation? orientation) async =>
+ super.noSuchMethod(
+ Invocation.method(#lockCaptureOrientation, [cameraId, orientation]));
+
+ @override
+ Future<void> unlockCaptureOrientation(int? cameraId) async => super
+ .noSuchMethod(Invocation.method(#unlockCaptureOrientation, [cameraId]));
+
+ @override
+ Future<double> getMaxZoomLevel(int? cameraId) async => super.noSuchMethod(
+ Invocation.method(#getMaxZoomLevel, [cameraId]),
+ returnValue: 1.0,
+ );
+
+ @override
+ Future<double> getMinZoomLevel(int? cameraId) async => super.noSuchMethod(
+ Invocation.method(#getMinZoomLevel, [cameraId]),
+ returnValue: 0.0,
+ );
+
+ @override
+ Future<void> setZoomLevel(int? cameraId, double? zoom) async =>
+ super.noSuchMethod(Invocation.method(#setZoomLevel, [cameraId, zoom]));
+
+ @override
+ Future<void> setFlashMode(int? cameraId, FlashMode? mode) async =>
+ super.noSuchMethod(Invocation.method(#setFlashMode, [cameraId, mode]));
+
+ @override
+ Future<void> setExposureMode(int? cameraId, ExposureMode? mode) async =>
+ super.noSuchMethod(Invocation.method(#setExposureMode, [cameraId, mode]));
+
+ @override
+ Future<void> setExposurePoint(int? cameraId, Point<double>? point) async =>
+ super.noSuchMethod(
+ Invocation.method(#setExposurePoint, [cameraId, point]));
+
+ @override
+ Future<double> getMinExposureOffset(int? cameraId) async =>
+ super.noSuchMethod(
+ Invocation.method(#getMinExposureOffset, [cameraId]),
+ returnValue: 0.0,
+ );
+
+ @override
+ Future<double> getMaxExposureOffset(int? cameraId) async =>
+ super.noSuchMethod(
+ Invocation.method(#getMaxExposureOffset, [cameraId]),
+ returnValue: 1.0,
+ );
+
+ @override
+ Future<double> getExposureOffsetStepSize(int? cameraId) async =>
+ super.noSuchMethod(
+ Invocation.method(#getExposureOffsetStepSize, [cameraId]),
+ returnValue: 1.0,
+ );
+
+ @override
+ Future<double> setExposureOffset(int? cameraId, double? offset) async =>
+ super.noSuchMethod(
+ Invocation.method(#setExposureOffset, [cameraId, offset]),
+ returnValue: 1.0,
+ );
}
class MockCameraDescription extends CameraDescription {
+ /// Creates a new camera description with the given properties.
+ MockCameraDescription()
+ : super(
+ name: 'Test',
+ lensDirection: CameraLensDirection.back,
+ sensorOrientation: 0,
+ );
+
@override
CameraLensDirection get lensDirection => CameraLensDirection.back;
diff --git a/packages/camera/camera/test/camera_value_test.dart b/packages/camera/camera/test/camera_value_test.dart
index c365f6d..de7971d 100644
--- a/packages/camera/camera/test/camera_value_test.dart
+++ b/packages/camera/camera/test/camera_value_test.dart
@@ -24,9 +24,11 @@
flashMode: FlashMode.auto,
exposureMode: ExposureMode.auto,
exposurePointSupported: true,
+ focusMode: FocusMode.auto,
deviceOrientation: DeviceOrientation.portraitUp,
lockedCaptureOrientation: DeviceOrientation.portraitUp,
recordingOrientation: DeviceOrientation.portraitUp,
+ focusPointSupported: true,
);
expect(cameraValue, isA<CameraValue>());
@@ -58,8 +60,9 @@
expect(cameraValue.isTakingPicture, isFalse);
expect(cameraValue.isStreamingImages, isFalse);
expect(cameraValue.flashMode, FlashMode.auto);
- expect(cameraValue.exposureMode, null);
+ expect(cameraValue.exposureMode, ExposureMode.auto);
expect(cameraValue.exposurePointSupported, false);
+ expect(cameraValue.focusMode, FocusMode.auto);
expect(cameraValue.deviceOrientation, DeviceOrientation.portraitUp);
expect(cameraValue.lockedCaptureOrientation, null);
expect(cameraValue.recordingOrientation, null);
@@ -78,7 +81,8 @@
expect(cameraValue.isTakingPicture, isFalse);
expect(cameraValue.isStreamingImages, isFalse);
expect(cameraValue.flashMode, FlashMode.auto);
- expect(cameraValue.exposureMode, null);
+ expect(cameraValue.focusMode, FocusMode.auto);
+ expect(cameraValue.exposureMode, ExposureMode.auto);
expect(cameraValue.exposurePointSupported, false);
expect(cameraValue.deviceOrientation, DeviceOrientation.portraitUp);
expect(cameraValue.lockedCaptureOrientation, null);
diff --git a/packages/camera/camera/test/utils/method_channel_mock.dart b/packages/camera/camera/test/utils/method_channel_mock.dart
index cdf393f..fdbd9a1 100644
--- a/packages/camera/camera/test/utils/method_channel_mock.dart
+++ b/packages/camera/camera/test/utils/method_channel_mock.dart
@@ -5,15 +5,15 @@
import 'package:flutter/services.dart';
class MethodChannelMock {
- final Duration delay;
+ final Duration? delay;
final MethodChannel methodChannel;
final Map<String, dynamic> methods;
final log = <MethodCall>[];
MethodChannelMock({
- String channelName,
+ required String channelName,
this.delay,
- this.methods,
+ required this.methods,
}) : methodChannel = MethodChannel(channelName) {
methodChannel.setMockMethodCallHandler(_handler);
}
diff --git a/script/nnbd_plugins.sh b/script/nnbd_plugins.sh
index a2c22c6..9a8f771 100644
--- a/script/nnbd_plugins.sh
+++ b/script/nnbd_plugins.sh
@@ -9,6 +9,7 @@
"android_intent"
"battery"
"camera"
+ "camera_platform_interface"
"connectivity"
"cross_file"
"device_info"
@@ -38,8 +39,8 @@
# building the all plugins app. This list should be kept empty.
readonly NON_NNBD_PLUGINS_LIST=(
- "camera"
- "google_maps_flutter" # half migrated
+ #"camera"
+ "google_maps_flutter"
# "image_picker"
# "in_app_purchase"
# "quick_actions"