-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(sensors_plus)!: Migrate to dart:js_interop #2697
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
feat(sensors_plus)!: Migrate to dart:js_interop #2697
Conversation
c3a3acb
to
98d768c
Compare
98d768c
to
3ff6c97
Compare
Oh, this looks nice! Thanks! I'll have a look regarding the sensors if there is a way to test this. Also, this doesn't depend on |
Thanks for the quick response! |
I did a quick run on my Linux machine + chrome both On
on your PR I get the following:
I will check on MacOS + Chrome |
Similar errors, slightly different, on macOS + Chrome:
The PR code:
In theory, it is all well-supported in chrome, but I have the sensation it never worked before. Looking at the documentation https://developer.mozilla.org/en-US/docs/Web/API/Sensor_APIs we are supposed to query for permissions, but that doesn't seem to happen here at all. ![]() "could not connect to a sensor" is the only error visible. |
Thank you! |
hmm, I tested following codes. The permissions are already granted. import 'package:web/web.dart';
~~~
@override
Stream<AccelerometerEvent> accelerometerEventStream({
Duration samplingPeriod = SensorInterval.normalInterval,
}) {
if (_accelerometerStreamController == null) {
_accelerometerStreamController = StreamController<AccelerometerEvent>();
_featureDetected(
() async {
final status = await window.navigator.permissions
.query(
PermissionDescriptor(
name: 'accelerometer',
),
)
.toDart;
print('accelerometer: name: ${status.name}, state: ${status.state}');
result.
I will continue to investigate. |
https://koji-1009.github.io/plus_plugins/ I uploaded example app. When I open it in chrome on my Android phone, it seems to be working as expected. |
Great job! Checked on my phone and it works as well. Is the code in the PR up-to-date? |
Yes, this PR code is up to date. |
Thanks! |
Thanks to you! |
Description
APIs such as Accelerometer are defined independently using dart:js_interop.
Do you know how to see the sensor change in the browser, I tried emulation with chrome dev tools but could not see the value change.
https://developer.chrome.com/docs/devtools/sensors
Related Issues
package:web
to support WASM #2602Checklist
CHANGELOG.md
nor the plugin version inpubspec.yaml
files.flutter analyze
) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?
!
in the title as explained in Conventional Commits).