I have the following functional javascript code to demonstrate what I want to achieve. It should output the object passed to the method, and then the value of the property "a".
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script>
window.theObjectCall = function(x) {
console.log(x);
console.log(x.a);
}
</script>
<script src="main.dart.js" type="application/javascript"></script>
</body>
</html>
I have the following dart code, and it works, but "a" is not accessible as I expect.
@JS('window')
library whatever;
import 'dart:js';
import 'package:js/js.dart';
@JS('theObjectCall') // Accessing method getCurrentPosition from Geolocation API
external void theJsObjectCall(JsObject theObject);
void someJsCallWithObject() {
var object = JsObject(context['Object']);
object['a'] = 'xxx';
theJsObjectCall(object);
}
Executing the below logs "undefined" in the console.