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

- Fixes bug where old camera resources were not disposed when switching between camera descriptions
- Fixes bug where _deviceOrientationSubscription was recreated every time the camera description was changed

## 0.10.5+2

* Fixes unawaited_futures violations.
Expand Down
9 changes: 8 additions & 1 deletion packages/camera/camera/lib/src/camera_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -294,11 +294,12 @@ class CameraController extends ValueNotifier<CameraValue> {
'initialize was called on a disposed CameraController',
);
}

try {
final Completer<CameraInitializedEvent> initializeCompleter =
Completer<CameraInitializedEvent>();

_deviceOrientationSubscription = CameraPlatform.instance
_deviceOrientationSubscription ??= CameraPlatform.instance
.onDeviceOrientationChanged()
.listen((DeviceOrientationChangedEvent event) {
value = value.copyWith(
Expand Down Expand Up @@ -402,6 +403,12 @@ class CameraController extends ValueNotifier<CameraValue> {
await CameraPlatform.instance.setDescriptionWhileRecording(description);
value = value.copyWith(description: description);
} else {
// dispose resources from previous camera description
if (_initCalled != null) {
await _initCalled;
await CameraPlatform.instance.dispose(_cameraId);
}

await _initializeWithDescription(description);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: A Flutter plugin for controlling the camera. Supports previewing
Dart.
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
version: 0.10.5+2
version: 0.10.6

environment:
sdk: ">=2.18.0 <4.0.0"
Expand Down