-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Uncaught RuntimeError: illegal cast - when trying to access string passed from Javascript to dart wasm #55715
Comments
Prefer using Here's an example: import 'dart:js_interop';
@JS()
external set foo(JSFunction f);
void main() {
void f(JSString x) {
print(x.toString());
}
foo = f.toJS;
} Here, we wrap a Dart function with a JS function and set it in the property |
(Maybe also use |
I missed that. :) Yes, convert it back into a |
Thanks @srujzs @lrhn for the support. With your suggestions, I modified my code as follows import 'dart:js_interop';
@JS()
external set _onKeyup(JSFunction fn);
void main() {
_onKeyup = _onKeyupDart.toJS;
}
void _onKeyupDart(JSString val) {
print(val.toDart);
} Now from the JavaScript side |
I have exported the following function in my dart wasm code
but whe I try to invoke this method from the javascript side,
I get the following error:
It points out to the following place in wasm library
Am I doing this the wrong way or is this an issue with compiler ?
PS: I was playing around with the following repo
https://github.com/mit-mit/sandbox/tree/main/demos/webwasm
The text was updated successfully, but these errors were encountered: