Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Revert "Fix examples analyze"
This reverts commit 4db1858.
  • Loading branch information
camsim99 committed Jan 17, 2023
commit ca483a7a2a4306de6f42f09e72a59f2c39f756b8
23 changes: 15 additions & 8 deletions packages/camera/camera/lib/src/camera_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:camera_platform_interface/camera_platform_interface.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:quiver/core.dart';

import '../camera.dart';

Expand Down Expand Up @@ -180,12 +181,16 @@ class CameraValue {
exposurePointSupported ?? this.exposurePointSupported,
focusPointSupported: focusPointSupported ?? this.focusPointSupported,
deviceOrientation: deviceOrientation ?? this.deviceOrientation,
lockedCaptureOrientation:
lockedCaptureOrientation ?? this.lockedCaptureOrientation,
recordingOrientation: recordingOrientation ?? this.recordingOrientation,
lockedCaptureOrientation: lockedCaptureOrientation == null
? this.lockedCaptureOrientation
: lockedCaptureOrientation.orNull,
recordingOrientation: recordingOrientation == null
? this.recordingOrientation
: recordingOrientation.orNull,
isPreviewPaused: isPreviewPaused ?? this.isPreviewPaused,
previewPauseOrientation:
previewPauseOrientation ?? this.previewPauseOrientation,
previewPauseOrientation: previewPauseOrientation == null
? this.previewPauseOrientation
: previewPauseOrientation.orNull,
);
}

Expand Down Expand Up @@ -367,7 +372,8 @@ class CameraController extends ValueNotifier<CameraValue> {
}
try {
await CameraPlatform.instance.resumePreview(_cameraId);
value = value.copyWith(isPreviewPaused: false);
value =
value.copyWith(isPreviewPaused: false, previewPauseOrientation: null);
} on PlatformException catch (e) {
throw CameraException(e.code, e.message);
}
Expand Down Expand Up @@ -519,7 +525,8 @@ class CameraController extends ValueNotifier<CameraValue> {
try {
final XFile file =
await CameraPlatform.instance.stopVideoRecording(_cameraId);
value = value.copyWith(isRecordingVideo: false);
value =
value.copyWith(isRecordingVideo: false, recordingOrientation: null);
return file;
} on PlatformException catch (e) {
throw CameraException(e.code, e.message);
Expand Down Expand Up @@ -757,7 +764,7 @@ class CameraController extends ValueNotifier<CameraValue> {
Future<void> unlockCaptureOrientation() async {
try {
await CameraPlatform.instance.unlockCaptureOrientation(_cameraId);
value = value.copyWith();
value = value.copyWith(lockedCaptureOrientation: null);
} on PlatformException catch (e) {
throw CameraException(e.code, e.message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:camera_platform_interface/camera_platform_interface.dart';
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 {
Expand Down Expand Up @@ -107,6 +108,7 @@ class CameraValue {
FocusMode? focusMode,
bool? exposurePointSupported,
bool? focusPointSupported,
bool? isPreviewPaused,
DeviceOrientation? deviceOrientation,
DeviceOrientation? lockedCaptureOrientation,
DeviceOrientation? recordingOrientation,
Expand All @@ -124,12 +126,16 @@ class CameraValue {
exposureMode: exposureMode ?? this.exposureMode,
focusMode: focusMode ?? this.focusMode,
deviceOrientation: deviceOrientation ?? this.deviceOrientation,
lockedCaptureOrientation:
lockedCaptureOrientation ?? this.lockedCaptureOrientation,
recordingOrientation: recordingOrientation ?? this.recordingOrientation,
lockedCaptureOrientation: lockedCaptureOrientation == null
? this.lockedCaptureOrientation
: lockedCaptureOrientation.orNull,
recordingOrientation: recordingOrientation == null
? this.recordingOrientation
: recordingOrientation.orNull,
isPreviewPaused: isPreviewPaused ?? this.isPreviewPaused,
previewPauseOrientation:
previewPauseOrientation ?? this.previewPauseOrientation,
previewPauseOrientation: previewPauseOrientation == null
? this.previewPauseOrientation
: previewPauseOrientation.orNull,
);
}

Expand Down Expand Up @@ -264,7 +270,8 @@ class CameraController extends ValueNotifier<CameraValue> {
/// Resumes the current camera preview
Future<void> resumePreview() async {
await CameraPlatform.instance.resumePreview(_cameraId);
value = value.copyWith(isPreviewPaused: false);
value =
value.copyWith(isPreviewPaused: false, previewPauseOrientation: null);
}

/// Captures an image and returns the file where it was saved.
Expand Down Expand Up @@ -324,6 +331,7 @@ class CameraController extends ValueNotifier<CameraValue> {
value = value.copyWith(
isRecordingVideo: false,
isRecordingPaused: false,
recordingOrientation: null,
);
return file;
}
Expand Down Expand Up @@ -398,6 +406,7 @@ class CameraController extends ValueNotifier<CameraValue> {
/// Unlocks the capture orientation.
Future<void> unlockCaptureOrientation() async {
await CameraPlatform.instance.unlockCaptureOrientation(_cameraId);
value = value.copyWith(lockedCaptureOrientation: null);
}

/// Sets the focus mode for taking pictures.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:camera_platform_interface/camera_platform_interface.dart';
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 {
Expand Down Expand Up @@ -124,12 +125,16 @@ class CameraValue {
exposureMode: exposureMode ?? this.exposureMode,
focusMode: focusMode ?? this.focusMode,
deviceOrientation: deviceOrientation ?? this.deviceOrientation,
lockedCaptureOrientation:
lockedCaptureOrientation ?? this.lockedCaptureOrientation,
recordingOrientation: recordingOrientation ?? this.recordingOrientation,
lockedCaptureOrientation: lockedCaptureOrientation == null
? this.lockedCaptureOrientation
: lockedCaptureOrientation.orNull,
recordingOrientation: recordingOrientation == null
? this.recordingOrientation
: recordingOrientation.orNull,
isPreviewPaused: isPreviewPaused ?? this.isPreviewPaused,
previewPauseOrientation:
previewPauseOrientation ?? this.previewPauseOrientation,
previewPauseOrientation: previewPauseOrientation == null
? this.previewPauseOrientation
: previewPauseOrientation.orNull,
);
}

Expand Down Expand Up @@ -264,7 +269,8 @@ class CameraController extends ValueNotifier<CameraValue> {
/// Resumes the current camera preview
Future<void> resumePreview() async {
await CameraPlatform.instance.resumePreview(_cameraId);
value = value.copyWith(isPreviewPaused: false);
value =
value.copyWith(isPreviewPaused: false, previewPauseOrientation: null);
}

/// Captures an image and returns the file where it was saved.
Expand Down Expand Up @@ -321,7 +327,10 @@ class CameraController extends ValueNotifier<CameraValue> {

final XFile file =
await CameraPlatform.instance.stopVideoRecording(_cameraId);
value = value.copyWith(isRecordingVideo: false);
value = value.copyWith(
isRecordingVideo: false,
recordingOrientation: null,
);
return file;
}

Expand Down Expand Up @@ -395,6 +404,7 @@ class CameraController extends ValueNotifier<CameraValue> {
/// Unlocks the capture orientation.
Future<void> unlockCaptureOrientation() async {
await CameraPlatform.instance.unlockCaptureOrientation(_cameraId);
value = value.copyWith(lockedCaptureOrientation: null);
}

/// Sets the focus mode for taking pictures.
Expand Down