diff --git a/permission_handler_html/CHANGELOG.md b/permission_handler_html/CHANGELOG.md index e3859a98..09f6d7e6 100644 --- a/permission_handler_html/CHANGELOG.md +++ b/permission_handler_html/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.3+5 + +- wasm compatibility: Changed way how `window.navigator.mediaDevices` is accessed + ## 0.1.3+4 - Fixes a bug causing the application to crash when running on HTTP protocol (not HTTPS or localhost) and the `window.navigator.mediaDevices` property is `null`. diff --git a/permission_handler_html/lib/permission_handler_html.dart b/permission_handler_html/lib/permission_handler_html.dart index 5fa6e469..8be2fa7c 100644 --- a/permission_handler_html/lib/permission_handler_html.dart +++ b/permission_handler_html/lib/permission_handler_html.dart @@ -1,6 +1,5 @@ import 'dart:async'; import 'dart:js_interop_unsafe'; -import 'dart:js_util' as js_util; import 'package:web/web.dart' as web; @@ -12,10 +11,12 @@ import 'web_delegate.dart'; /// Platform implementation of the permission_handler Flutter plugin. class WebPermissionHandler extends PermissionHandlerPlatform { - static final web.MediaDevices? _devices = - js_util.hasProperty(web.window.navigator, 'mediaDevices') - ? js_util.getProperty(web.window.navigator, 'mediaDevices') - : null; + static final web.MediaDevices? _devices = (() { + if (!web.window.navigator.has('mediaDevices')) { + return null; + } + return web.window.navigator.mediaDevices; + })(); static final web.Geolocation _geolocation = web.window.navigator.geolocation; static final web.Permissions? _htmlPermissions = (() { // Using unsafe interop to check availability of `permissions`. diff --git a/permission_handler_html/pubspec.yaml b/permission_handler_html/pubspec.yaml index a14ad00b..2b3a022e 100644 --- a/permission_handler_html/pubspec.yaml +++ b/permission_handler_html/pubspec.yaml @@ -1,6 +1,6 @@ name: permission_handler_html description: Permission plugin for Flutter. This plugin provides the web API to request and check permissions. -version: 0.1.3+4 +version: 0.1.3+5 homepage: https://github.com/baseflow/flutter-permission-handler