[camera] Remove deprecated Optional type (#6870)
* Remove Optional
* Undo accidental order change
* Fix examples analyze
* Remove unused import
* Bump versions
* Correct version
diff --git a/packages/camera/camera/CHANGELOG.md b/packages/camera/camera/CHANGELOG.md
index f5d87a6..84c7559 100644
--- a/packages/camera/camera/CHANGELOG.md
+++ b/packages/camera/camera/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.10.1
+
+* Remove usage of deprecated quiver Optional type.
+
## 0.10.0+5
* Updates code for stricter lint checks.
diff --git a/packages/camera/camera/lib/src/camera_controller.dart b/packages/camera/camera/lib/src/camera_controller.dart
index ed1c951..b05e61b 100644
--- a/packages/camera/camera/lib/src/camera_controller.dart
+++ b/packages/camera/camera/lib/src/camera_controller.dart
@@ -9,7 +9,6 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
-import 'package:quiver/core.dart';
import '../camera.dart';
@@ -161,10 +160,10 @@
bool? exposurePointSupported,
bool? focusPointSupported,
DeviceOrientation? deviceOrientation,
- Optional<DeviceOrientation>? lockedCaptureOrientation,
- Optional<DeviceOrientation>? recordingOrientation,
+ DeviceOrientation? lockedCaptureOrientation,
+ DeviceOrientation? recordingOrientation,
bool? isPreviewPaused,
- Optional<DeviceOrientation>? previewPauseOrientation,
+ DeviceOrientation? previewPauseOrientation,
}) {
return CameraValue(
isInitialized: isInitialized ?? this.isInitialized,
@@ -181,16 +180,12 @@
exposurePointSupported ?? this.exposurePointSupported,
focusPointSupported: focusPointSupported ?? this.focusPointSupported,
deviceOrientation: deviceOrientation ?? this.deviceOrientation,
- lockedCaptureOrientation: lockedCaptureOrientation == null
- ? this.lockedCaptureOrientation
- : lockedCaptureOrientation.orNull,
- recordingOrientation: recordingOrientation == null
- ? this.recordingOrientation
- : recordingOrientation.orNull,
+ lockedCaptureOrientation:
+ lockedCaptureOrientation ?? this.lockedCaptureOrientation,
+ recordingOrientation: recordingOrientation ?? this.recordingOrientation,
isPreviewPaused: isPreviewPaused ?? this.isPreviewPaused,
- previewPauseOrientation: previewPauseOrientation == null
- ? this.previewPauseOrientation
- : previewPauseOrientation.orNull,
+ previewPauseOrientation:
+ previewPauseOrientation ?? this.previewPauseOrientation,
);
}
@@ -358,8 +353,8 @@
await CameraPlatform.instance.pausePreview(_cameraId);
value = value.copyWith(
isPreviewPaused: true,
- previewPauseOrientation: Optional<DeviceOrientation>.of(
- value.lockedCaptureOrientation ?? value.deviceOrientation));
+ previewPauseOrientation:
+ value.lockedCaptureOrientation ?? value.deviceOrientation);
} on PlatformException catch (e) {
throw CameraException(e.code, e.message);
}
@@ -372,9 +367,7 @@
}
try {
await CameraPlatform.instance.resumePreview(_cameraId);
- value = value.copyWith(
- isPreviewPaused: false,
- previewPauseOrientation: const Optional<DeviceOrientation>.absent());
+ value = value.copyWith(isPreviewPaused: false);
} on PlatformException catch (e) {
throw CameraException(e.code, e.message);
}
@@ -505,8 +498,8 @@
value = value.copyWith(
isRecordingVideo: true,
isRecordingPaused: false,
- recordingOrientation: Optional<DeviceOrientation>.of(
- value.lockedCaptureOrientation ?? value.deviceOrientation));
+ recordingOrientation:
+ value.lockedCaptureOrientation ?? value.deviceOrientation);
} on PlatformException catch (e) {
throw CameraException(e.code, e.message);
}
@@ -526,10 +519,7 @@
try {
final XFile file =
await CameraPlatform.instance.stopVideoRecording(_cameraId);
- value = value.copyWith(
- isRecordingVideo: false,
- recordingOrientation: const Optional<DeviceOrientation>.absent(),
- );
+ value = value.copyWith(isRecordingVideo: false);
return file;
} on PlatformException catch (e) {
throw CameraException(e.code, e.message);
@@ -747,8 +737,7 @@
await CameraPlatform.instance.lockCaptureOrientation(
_cameraId, orientation ?? value.deviceOrientation);
value = value.copyWith(
- lockedCaptureOrientation: Optional<DeviceOrientation>.of(
- orientation ?? value.deviceOrientation));
+ lockedCaptureOrientation: orientation ?? value.deviceOrientation);
} on PlatformException catch (e) {
throw CameraException(e.code, e.message);
}
@@ -768,8 +757,7 @@
Future<void> unlockCaptureOrientation() async {
try {
await CameraPlatform.instance.unlockCaptureOrientation(_cameraId);
- value = value.copyWith(
- lockedCaptureOrientation: const Optional<DeviceOrientation>.absent());
+ value = value.copyWith();
} on PlatformException catch (e) {
throw CameraException(e.code, e.message);
}
diff --git a/packages/camera/camera/pubspec.yaml b/packages/camera/camera/pubspec.yaml
index a867a5a..33d704e 100644
--- a/packages/camera/camera/pubspec.yaml
+++ b/packages/camera/camera/pubspec.yaml
@@ -4,7 +4,7 @@
Dart.
repository: https://github.com/flutter/plugins/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.10.0+5
+version: 0.10.1
environment:
sdk: ">=2.14.0 <3.0.0"
diff --git a/packages/camera/camera/test/camera_preview_test.dart b/packages/camera/camera/test/camera_preview_test.dart
index bedb0ea..546f4e9 100644
--- a/packages/camera/camera/test/camera_preview_test.dart
+++ b/packages/camera/camera/test/camera_preview_test.dart
@@ -8,7 +8,6 @@
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
-import 'package:quiver/core.dart';
class FakeController extends ValueNotifier<CameraValue>
implements CameraController {
@@ -133,11 +132,8 @@
isInitialized: true,
isRecordingVideo: true,
deviceOrientation: DeviceOrientation.portraitUp,
- lockedCaptureOrientation:
- const Optional<DeviceOrientation>.fromNullable(
- DeviceOrientation.landscapeRight),
- recordingOrientation: const Optional<DeviceOrientation>.fromNullable(
- DeviceOrientation.landscapeLeft),
+ lockedCaptureOrientation: DeviceOrientation.landscapeRight,
+ recordingOrientation: DeviceOrientation.landscapeLeft,
previewSize: const Size(480, 640),
);
@@ -167,11 +163,8 @@
controller.value = controller.value.copyWith(
isInitialized: true,
deviceOrientation: DeviceOrientation.portraitUp,
- lockedCaptureOrientation:
- const Optional<DeviceOrientation>.fromNullable(
- DeviceOrientation.landscapeRight),
- recordingOrientation: const Optional<DeviceOrientation>.fromNullable(
- DeviceOrientation.landscapeLeft),
+ lockedCaptureOrientation: DeviceOrientation.landscapeRight,
+ recordingOrientation: DeviceOrientation.landscapeLeft,
previewSize: const Size(480, 640),
);
@@ -201,8 +194,7 @@
controller.value = controller.value.copyWith(
isInitialized: true,
deviceOrientation: DeviceOrientation.portraitUp,
- recordingOrientation: const Optional<DeviceOrientation>.fromNullable(
- DeviceOrientation.landscapeLeft),
+ recordingOrientation: DeviceOrientation.landscapeLeft,
previewSize: const Size(480, 640),
);
diff --git a/packages/camera/camera/test/camera_test.dart b/packages/camera/camera/test/camera_test.dart
index 3c12648..2138f2d 100644
--- a/packages/camera/camera/test/camera_test.dart
+++ b/packages/camera/camera/test/camera_test.dart
@@ -13,7 +13,6 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';
-import 'package:quiver/core.dart';
List<CameraDescription> get mockAvailableCameras => <CameraDescription>[
const CameraDescription(
@@ -1191,8 +1190,7 @@
cameraController.value = cameraController.value.copyWith(
isPreviewPaused: false,
deviceOrientation: DeviceOrientation.portraitUp,
- lockedCaptureOrientation:
- Optional<DeviceOrientation>.of(DeviceOrientation.landscapeRight));
+ lockedCaptureOrientation: DeviceOrientation.landscapeRight);
await cameraController.pausePreview();
diff --git a/packages/camera/camera_android/CHANGELOG.md b/packages/camera/camera_android/CHANGELOG.md
index 80f03df..1b07c30 100644
--- a/packages/camera/camera_android/CHANGELOG.md
+++ b/packages/camera/camera_android/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.10.2
+
+* Remove usage of deprecated quiver Optional type.
+
## 0.10.1
* Implements an option to also stream when recording a video.
diff --git a/packages/camera/camera_android/example/lib/camera_controller.dart b/packages/camera/camera_android/example/lib/camera_controller.dart
index 94d8ef6..79bf4e8 100644
--- a/packages/camera/camera_android/example/lib/camera_controller.dart
+++ b/packages/camera/camera_android/example/lib/camera_controller.dart
@@ -8,7 +8,6 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
-import 'package:quiver/core.dart';
/// The state of a [CameraController].
class CameraValue {
@@ -109,10 +108,10 @@
bool? exposurePointSupported,
bool? focusPointSupported,
DeviceOrientation? deviceOrientation,
- Optional<DeviceOrientation>? lockedCaptureOrientation,
- Optional<DeviceOrientation>? recordingOrientation,
+ DeviceOrientation? lockedCaptureOrientation,
+ DeviceOrientation? recordingOrientation,
bool? isPreviewPaused,
- Optional<DeviceOrientation>? previewPauseOrientation,
+ DeviceOrientation? previewPauseOrientation,
}) {
return CameraValue(
isInitialized: isInitialized ?? this.isInitialized,
@@ -125,16 +124,12 @@
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 ?? this.lockedCaptureOrientation,
+ recordingOrientation: recordingOrientation ?? this.recordingOrientation,
isPreviewPaused: isPreviewPaused ?? this.isPreviewPaused,
- previewPauseOrientation: previewPauseOrientation == null
- ? this.previewPauseOrientation
- : previewPauseOrientation.orNull,
+ previewPauseOrientation:
+ previewPauseOrientation ?? this.previewPauseOrientation,
);
}
@@ -262,16 +257,14 @@
await CameraPlatform.instance.pausePreview(_cameraId);
value = value.copyWith(
isPreviewPaused: true,
- previewPauseOrientation: Optional<DeviceOrientation>.of(
- value.lockedCaptureOrientation ?? value.deviceOrientation));
+ previewPauseOrientation:
+ value.lockedCaptureOrientation ?? value.deviceOrientation);
}
/// Resumes the current camera preview
Future<void> resumePreview() async {
await CameraPlatform.instance.resumePreview(_cameraId);
- value = value.copyWith(
- isPreviewPaused: false,
- previewPauseOrientation: const Optional<DeviceOrientation>.absent());
+ value = value.copyWith(isPreviewPaused: false);
}
/// Captures an image and returns the file where it was saved.
@@ -314,8 +307,8 @@
isRecordingVideo: true,
isRecordingPaused: false,
isStreamingImages: streamCallback != null,
- recordingOrientation: Optional<DeviceOrientation>.of(
- value.lockedCaptureOrientation ?? value.deviceOrientation));
+ recordingOrientation:
+ value.lockedCaptureOrientation ?? value.deviceOrientation);
}
/// Stops the video recording and returns the file where it was saved.
@@ -331,7 +324,6 @@
value = value.copyWith(
isRecordingVideo: false,
isRecordingPaused: false,
- recordingOrientation: const Optional<DeviceOrientation>.absent(),
);
return file;
}
@@ -400,16 +392,12 @@
Future<void> lockCaptureOrientation() async {
await CameraPlatform.instance
.lockCaptureOrientation(_cameraId, value.deviceOrientation);
- value = value.copyWith(
- lockedCaptureOrientation:
- Optional<DeviceOrientation>.of(value.deviceOrientation));
+ value = value.copyWith(lockedCaptureOrientation: value.deviceOrientation);
}
/// Unlocks the capture orientation.
Future<void> unlockCaptureOrientation() async {
await CameraPlatform.instance.unlockCaptureOrientation(_cameraId);
- value = value.copyWith(
- lockedCaptureOrientation: const Optional<DeviceOrientation>.absent());
}
/// Sets the focus mode for taking pictures.
diff --git a/packages/camera/camera_android/pubspec.yaml b/packages/camera/camera_android/pubspec.yaml
index 7ed5077..6f25af7 100644
--- a/packages/camera/camera_android/pubspec.yaml
+++ b/packages/camera/camera_android/pubspec.yaml
@@ -2,7 +2,7 @@
description: Android implementation of the camera plugin.
repository: https://github.com/flutter/plugins/tree/main/packages/camera/camera_android
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: ">=2.14.0 <3.0.0"
diff --git a/packages/camera/camera_avfoundation/CHANGELOG.md b/packages/camera/camera_avfoundation/CHANGELOG.md
index 641272a..9217f26 100644
--- a/packages/camera/camera_avfoundation/CHANGELOG.md
+++ b/packages/camera/camera_avfoundation/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.9.10
+
+* Remove usage of deprecated quiver Optional type.
+
## 0.9.9
* Implements option to also stream when recording a video.
diff --git a/packages/camera/camera_avfoundation/example/lib/camera_controller.dart b/packages/camera/camera_avfoundation/example/lib/camera_controller.dart
index 2fcd868..47c1f6f 100644
--- a/packages/camera/camera_avfoundation/example/lib/camera_controller.dart
+++ b/packages/camera/camera_avfoundation/example/lib/camera_controller.dart
@@ -8,7 +8,6 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
-import 'package:quiver/core.dart';
/// The state of a [CameraController].
class CameraValue {
@@ -109,10 +108,10 @@
bool? exposurePointSupported,
bool? focusPointSupported,
DeviceOrientation? deviceOrientation,
- Optional<DeviceOrientation>? lockedCaptureOrientation,
- Optional<DeviceOrientation>? recordingOrientation,
+ DeviceOrientation? lockedCaptureOrientation,
+ DeviceOrientation? recordingOrientation,
bool? isPreviewPaused,
- Optional<DeviceOrientation>? previewPauseOrientation,
+ DeviceOrientation? previewPauseOrientation,
}) {
return CameraValue(
isInitialized: isInitialized ?? this.isInitialized,
@@ -125,16 +124,12 @@
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 ?? this.lockedCaptureOrientation,
+ recordingOrientation: recordingOrientation ?? this.recordingOrientation,
isPreviewPaused: isPreviewPaused ?? this.isPreviewPaused,
- previewPauseOrientation: previewPauseOrientation == null
- ? this.previewPauseOrientation
- : previewPauseOrientation.orNull,
+ previewPauseOrientation:
+ previewPauseOrientation ?? this.previewPauseOrientation,
);
}
@@ -262,16 +257,14 @@
await CameraPlatform.instance.pausePreview(_cameraId);
value = value.copyWith(
isPreviewPaused: true,
- previewPauseOrientation: Optional<DeviceOrientation>.of(
- value.lockedCaptureOrientation ?? value.deviceOrientation));
+ previewPauseOrientation:
+ value.lockedCaptureOrientation ?? value.deviceOrientation);
}
/// Resumes the current camera preview
Future<void> resumePreview() async {
await CameraPlatform.instance.resumePreview(_cameraId);
- value = value.copyWith(
- isPreviewPaused: false,
- previewPauseOrientation: const Optional<DeviceOrientation>.absent());
+ value = value.copyWith(isPreviewPaused: false);
}
/// Captures an image and returns the file where it was saved.
@@ -314,8 +307,8 @@
isRecordingVideo: true,
isRecordingPaused: false,
isStreamingImages: streamCallback != null,
- recordingOrientation: Optional<DeviceOrientation>.of(
- value.lockedCaptureOrientation ?? value.deviceOrientation));
+ recordingOrientation:
+ value.lockedCaptureOrientation ?? value.deviceOrientation);
}
/// Stops the video recording and returns the file where it was saved.
@@ -328,10 +321,7 @@
final XFile file =
await CameraPlatform.instance.stopVideoRecording(_cameraId);
- value = value.copyWith(
- isRecordingVideo: false,
- recordingOrientation: const Optional<DeviceOrientation>.absent(),
- );
+ value = value.copyWith(isRecordingVideo: false);
return file;
}
@@ -399,16 +389,12 @@
Future<void> lockCaptureOrientation() async {
await CameraPlatform.instance
.lockCaptureOrientation(_cameraId, value.deviceOrientation);
- value = value.copyWith(
- lockedCaptureOrientation:
- Optional<DeviceOrientation>.of(value.deviceOrientation));
+ value = value.copyWith(lockedCaptureOrientation: value.deviceOrientation);
}
/// Unlocks the capture orientation.
Future<void> unlockCaptureOrientation() async {
await CameraPlatform.instance.unlockCaptureOrientation(_cameraId);
- value = value.copyWith(
- lockedCaptureOrientation: const Optional<DeviceOrientation>.absent());
}
/// Sets the focus mode for taking pictures.
diff --git a/packages/camera/camera_avfoundation/pubspec.yaml b/packages/camera/camera_avfoundation/pubspec.yaml
index e60f5e4..aa1c110 100644
--- a/packages/camera/camera_avfoundation/pubspec.yaml
+++ b/packages/camera/camera_avfoundation/pubspec.yaml
@@ -2,7 +2,7 @@
description: iOS implementation of the camera plugin.
repository: https://github.com/flutter/plugins/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.9.9
+version: 0.9.10
environment:
sdk: ">=2.14.0 <3.0.0"