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 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
Rebuild camera preview when camera value changes
  • Loading branch information
BeMacized committed Jul 27, 2021
commit 945516613bddf87a36effe9deff25bb83efedbd6
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+7

* Fix device orientation sometimes not affecting the camera preview orientation.

## 0.8.1+6

* Remove references to the Android V1 embedding.
Expand Down
28 changes: 17 additions & 11 deletions packages/camera/camera/lib/src/camera_preview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,23 @@ class CameraPreview extends StatelessWidget {
@override
Widget build(BuildContext context) {
return controller.value.isInitialized
? AspectRatio(
aspectRatio: _isLandscape()
? controller.value.aspectRatio
: (1 / controller.value.aspectRatio),
child: Stack(
fit: StackFit.expand,
children: [
_wrapInRotatedBox(child: controller.buildPreview()),
child ?? Container(),
],
),
? ValueListenableBuilder(
valueListenable: controller,
builder: (context, value, child) {
return AspectRatio(
aspectRatio: _isLandscape()
? controller.value.aspectRatio
: (1 / controller.value.aspectRatio),
child: Stack(
fit: StackFit.expand,
children: [
_wrapInRotatedBox(child: controller.buildPreview()),
child ?? Container(),
],
),
);
},
child: child,
)
: Container();
}
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 getting information about and controlling the
and streaming image buffers to dart.
repository: https://github.com/flutter/plugins/tree/master/packages/camera/camera
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
version: 0.8.1+6
version: 0.8.1+7

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down