File tree Expand file tree Collapse file tree 4 files changed +41
-1
lines changed
packages/camera/camera_web Expand file tree Collapse file tree 4 files changed +41
-1
lines changed Original file line number Diff line number Diff line change 1+ ## 0.3.5+3
2+
3+ * Fixes camera initialization failure on Safari by fixing a null check operator error using
4+ a nullable getter and null safe practices.
5+
16## 0.3.5+2
27
38* Fixes camera initialization failure on Firefox Android by using ` {video: true} ` instead
Original file line number Diff line number Diff line change @@ -708,6 +708,29 @@ void main() {
708708
709709 expect (facingMode, isNull);
710710 });
711+
712+ testWidgets ('returns null '
713+ 'when the facing mode setting is empty and '
714+ 'the facingMode capability is null' , (WidgetTester tester) async {
715+ mockVideoTrack.getSettings = () {
716+ return web.MediaTrackSettings (facingMode: '' );
717+ }.toJS;
718+ mockVideoTrack.getCapabilities = () {
719+ // Use the fake class that has no facingMode property
720+ return createJSInteropWrapper (FakeMediaTrackCapabilities ())
721+ as web.MediaTrackCapabilities ;
722+ }.toJS;
723+
724+ when (
725+ jsUtil.hasProperty (videoTrack, 'getCapabilities' .toJS),
726+ ).thenReturn (true );
727+
728+ final String ? facingMode = cameraService.getFacingModeForVideoTrack (
729+ videoTrack,
730+ );
731+
732+ expect (facingMode, isNull);
733+ });
711734 });
712735 });
713736
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import 'dart:ui';
1111// ignore_for_file: implementation_imports
1212import 'package:camera_web/src/camera.dart' ;
1313import 'package:camera_web/src/camera_service.dart' ;
14+ import 'package:camera_web/src/pkg_web_tweaks.dart' ;
1415import 'package:camera_web/src/shims/dart_js_util.dart' ;
1516import 'package:camera_web/src/types/types.dart' ;
1617import 'package:mockito/annotations.dart' ;
@@ -284,3 +285,14 @@ class MockEventStreamProvider<T extends web.Event> extends Mock
284285 as ElementStream <T >;
285286 }
286287}
288+
289+ /// A fake [web.MediaTrackCapabilities] where facingMode is null/undefined.
290+ ///
291+ /// Used to test null-safe handling when the browser doesn't provide
292+ /// the facingMode capability.
293+ @JSExport ()
294+ class FakeMediaTrackCapabilities {
295+
296+ // Dummy property required by @JSExport
297+ bool get dummy => true ;
298+ }
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ name: camera_web
22description : A Flutter plugin for getting information about and controlling the camera on Web.
33repository : https://github.com/flutter/packages/tree/main/packages/camera/camera_web
44issue_tracker : https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+camera%22
5- version : 0.3.5+2
5+ version : 0.3.5+3
66
77environment :
88 sdk : ^3.8.0
You can’t perform that action at this time.
0 commit comments