Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Closed
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
4 changes: 4 additions & 0 deletions packages/camera/camera/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.8.1-nullsafety

- Added freeze parameter to CameraPreview.

## 0.8.0-nullsafety.3

* Updates the example code listed in the [README.md](README.md), so it runs without errors when you simply copy/ paste it into a Flutter App.
Expand Down
11 changes: 8 additions & 3 deletions packages/camera/camera/lib/src/camera_preview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ import 'package:flutter/services.dart';
/// A widget showing a live camera preview.
class CameraPreview extends StatelessWidget {
/// Creates a preview widget for the given camera controller.
const CameraPreview(this.controller, {this.child});
const CameraPreview(this.controller, {this.freeze, this.child});

/// The controller for the camera that the preview is shown for.
final CameraController controller;

/// When true the preview will not be updated with new frames.
final bool freeze;

/// A widget to overlay on top of the camera preview
final Widget? child;

Expand All @@ -31,8 +34,10 @@ class CameraPreview extends StatelessWidget {
children: [
RotatedBox(
quarterTurns: _getQuarterTurns(),
child:
CameraPlatform.instance.buildPreview(controller.cameraId),
child: CameraPlatform.instance.buildPreview(
controller.cameraId,
freeze: freeze,
),
),
child ?? Container(),
],
Expand Down
4 changes: 2 additions & 2 deletions packages/camera/camera/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ name: camera
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.8.0-nullsafety.3
version: 0.8.1-nullsafety
homepage: https://github.com/flutter/plugins/tree/master/packages/camera/camera

dependencies:
flutter:
sdk: flutter

camera_platform_interface: ^2.0.0-nullsafety
camera_platform_interface: ^2.0.1-nullsafety

pedantic: ^1.10.0
quiver: ^3.0.0-nullsafety.3
Expand Down
4 changes: 4 additions & 0 deletions packages/camera/camera_platform_interface/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.1-nullsafety

- Added freeze parameter to buildPreview.

## 2.0.0-nullsafety

- Migrate to null safety.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,8 @@ class MethodChannelCamera extends CameraPlatform {
}

@override
Widget buildPreview(int cameraId) {
return Texture(textureId: cameraId);
Widget buildPreview(int cameraId, {bool freeze = false}) {
return Texture(textureId: cameraId, freeze: freeze);
}

/// Returns the flash mode as a String.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,9 @@ abstract class CameraPlatform extends PlatformInterface {
}

/// Returns a widget showing a live camera preview.
Widget buildPreview(int cameraId) {
///
/// When [freeze] is true the preview will not be updated with new frames.
Widget buildPreview(int cameraId, {bool freeze = false}) {
throw UnimplementedError('buildView() has not been implemented.');
}

Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera_platform_interface/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: A common platform interface for the camera plugin.
homepage: https://github.com/flutter/plugins/tree/master/packages/camera/camera_platform_interface
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 2.0.0-nullsafety
version: 2.0.1-nullsafety

dependencies:
flutter:
Expand Down