Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[camera] Removed the microphone permission request from availableCameras on Web #4263

4 changes: 4 additions & 0 deletions packages/camera/camera_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.2

* Changes `availableCameras` to not ask for the microphone permission.

## 0.3.1+4

* Removes obsolete null checks on non-nullable values.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,24 +101,18 @@ void main() {
);
});

testWidgets('requests video and audio permissions',
(WidgetTester tester) async {
testWidgets('requests video permissions', (WidgetTester tester) async {
final List<CameraDescription> _ =
await CameraPlatform.instance.availableCameras();

verify(
() => cameraService.getMediaStreamForOptions(
const CameraOptions(
audio: AudioConstraints(enabled: true),
),
),
() => cameraService.getMediaStreamForOptions(const CameraOptions()),
).called(1);
});

testWidgets(
'releases the camera stream '
'used to request video and audio permissions',
(WidgetTester tester) async {
'used to request video permissions', (WidgetTester tester) async {
final MockMediaStreamTrack videoTrack = MockMediaStreamTrack();

bool videoTrackStopped = false;
Expand All @@ -127,11 +121,7 @@ void main() {
});

when(
() => cameraService.getMediaStreamForOptions(
const CameraOptions(
audio: AudioConstraints(enabled: true),
),
),
() => cameraService.getMediaStreamForOptions(const CameraOptions()),
).thenAnswer(
(_) => Future<MediaStream>.value(
FakeMediaStream(<MediaStreamTrack>[videoTrack]),
Expand Down
6 changes: 1 addition & 5 deletions packages/camera/camera_web/lib/src/camera_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,7 @@ class CameraPlugin extends CameraPlatform {

// Request video and audio permissions.
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment is now incorrect.

final html.MediaStream cameraStream =
await _cameraService.getMediaStreamForOptions(
const CameraOptions(
audio: AudioConstraints(enabled: true),
),
);
await _cameraService.getMediaStreamForOptions(const CameraOptions());

// Release the camera stream used to request video and audio permissions.
Copy link
Contributor

Choose a reason for hiding this comment

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

As is this one.

cameraStream
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.1+4
version: 0.3.2

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