Skip to content
Open
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: 2 additions & 2 deletions packages/camera/camera_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## NEXT
## 0.3.5+1

* Updates minimum supported SDK version to Flutter 3.29/Dart 3.7.
* Fixes camera initialization failure on Firefox Android by using `{video: true}` instead of `{video: {}}` when no video constraints are specified.

## 0.3.5

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ void main() {
);
});

testWidgets('serializes to true when no constraints are provided', (
WidgetTester tester,
) async {
const VideoConstraints videoConstraints = VideoConstraints();
expect(videoConstraints.toMediaStreamConstraints().dartify(), isTrue);
});

testWidgets('supports value equality', (WidgetTester tester) async {
expect(
VideoConstraints(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,16 @@ class VideoConstraints {
// TODO(dit): package:web has a class for this. Use it instead of jsify and toJson.
/// Convert `this` to something that can be used on the browser.
JSAny toMediaStreamConstraints() {
return <String, Object>{
final Map<String, Object> constraints = <String, Object>{
if (width != null) 'width': width!.toJson(),
if (height != null) 'height': height!.toJson(),
if (facingMode != null) 'facingMode': facingMode!.toJson(),
if (deviceId != null) 'deviceId': <String, Object>{'exact': deviceId!},
}.jsify()!;
};

// Return true instead of empty object for better browser compatibility.
// Firefox Android rejects getUserMedia({video: {}}) but accepts {video: true}.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this bug documented anywhere that we can link to for context?

return constraints.isEmpty ? true.toJS : constraints.jsify()!;
}

@override
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: camera_web
description: A Flutter plugin for getting information about and controlling the camera on Web.
repository: https://github.com/flutter/packages/tree/main/packages/camera/camera_web
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
version: 0.3.5
version: 0.3.5+1

environment:
sdk: ^3.7.0
Expand Down