Skip to content

Commit

Permalink
Bug fix for WASM compilation (#1411)
Browse files Browse the repository at this point in the history
  • Loading branch information
dg76 authored Nov 20, 2024
1 parent 11d3baa commit cb27a13
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 4 additions & 0 deletions permission_handler_html/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`.
Expand Down
11 changes: 6 additions & 5 deletions permission_handler_html/lib/permission_handler_html.dart
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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`.
Expand Down
2 changes: 1 addition & 1 deletion permission_handler_html/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit cb27a13

Please sign in to comment.