Skip to content
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

geolocation.getCurrentPosition() fails with dart2js #44324

Closed
a14n opened this issue Nov 26, 2020 · 3 comments
Closed

geolocation.getCurrentPosition() fails with dart2js #44324

a14n opened this issue Nov 26, 2020 · 3 comments
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. P2 A bug or feature request we're likely to work on web-dart2js

Comments

@a14n
Copy link
Contributor

a14n commented Nov 26, 2020

With last stable Dart version (2.10.4) the following code throws an error when compile to js with dart2js:

import 'dart:html';

void main() async {
  print(await window.navigator.geolocation.getCurrentPosition());
}

The error in the js console:

js_helper.dart:1129 Uncaught TypeError: Instance of 'GeolocationPosition': type 'UnknownJavaScriptObject' is not a subtype of type 'Geoposition'
    at Object.wrapException (js_helper.dart:1129)
    at Object._failedAsCheck (rti.dart:1016)
    at Rti._generalNullableAsCheckImplementation [as _as] (rti.dart:1009)
    at Rti._installSpecializedAsCheck (rti.dart:933)
    at Geolocation_getCurrentPosition_closure.call$1 (html_dart2js.dart:16887)
    at invokeClosure (js_helper.dart:1825)
    at js_helper.dart:1857

EDIT : it works with webdev serve

@a14n
Copy link
Contributor Author

a14n commented Nov 26, 2020

/cc @sigmundch

@lrhn lrhn added the area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. label Nov 26, 2020
@sigmundch
Copy link
Member

@fishythefish @srujzs

@sigmundch sigmundch added P2 A bug or feature request we're likely to work on web-dart2js labels Nov 30, 2020
@arxarinze
Copy link

you can write an interop library to get ahead with your coding or you can use mine Geolocation PolyFill till the good peeps at dart solve this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. P2 A bug or feature request we're likely to work on web-dart2js
Projects
None yet
Development

No branches or pull requests

4 participants