Baseflow / flutter-permission-handler

Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions.
https://baseflow.com
MIT License
2.05k stars 859 forks source link

Bug fix for the DartError: TypeError: null: type 'Null' is not a subtype of type 'JSObject' #1407

Closed dg76 closed 4 days ago

dg76 commented 4 days ago

This PR fixes the bug mentioned here:

https://github.com/Baseflow/flutter-permission-handler/issues/1386

It seems that "mediaDevices" is only available when using https or localhost, but not when using e.g. http://0.0.0.0. Thus it is necessary to check if "mediaDevices" exists before accessing it.

mvanbeusekom commented 4 days ago

Hi @dg76,

Thank you for this contribution, it makes a lot of sense and I can indeed reproduce the issue. The suggested update looks really good, however do you mind updating the version number (increasing the patch number by one) and add an entry to the CHANGELOG.md (according to the changelog style guidelines)?

dg76 commented 4 days ago

No problem, I have changed the CHANGELOG.md and pubspec.yaml. It should appear as a second commit in the same pull request. Is it good now? Thank you for your quick response!

mvanbeusekom commented 4 days ago

Thanks again, I have just published version 0.1.3+4 of the permission_handler_html package to pub containing this fix.

dg76 commented 4 days ago

Thank you very much, I have configured my project to use 0.1.3+4 and it works correctly now. Thank you very much for publishing the new version so quickly!

LukasMirbt commented 2 days ago

Hi! Unfortunately it seems like the dart:js_util import breaks wasm compilation.

dg76 commented 2 days ago

I am sorry, I think I have fixed it with this PR: https://github.com/Baseflow/flutter-permission-handler/pull/1411

I am now using a method to access "mediaDevices" that was already used for "permissions" in the same file.

mvanbeusekom commented 2 days ago

I have just published version 0.1.3+5 of the permission_handler_html package containing the fix provided by @dg76

Thanks @dg76 for the quick fix.