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

What if I want JS and Dart to call each other? #7

Closed
Aaron009 opened this issue May 4, 2020 · 2 comments
Closed

What if I want JS and Dart to call each other? #7

Aaron009 opened this issue May 4, 2020 · 2 comments

Comments

@Aaron009
Copy link

Aaron009 commented May 4, 2020

Example

js

void jsFunc() {
    print('call jsFunc');
 	dartFunc();   
}

dart

void dartFunc() {
     print('call dartFunc');   
}

main() {
    jsFunc();
}

Output

call jsFunc
call dartFunc
@abner
Copy link
Owner

abner commented Aug 10, 2020

we are trying to add support to this feature in next version.

@abner
Copy link
Owner

abner commented Sep 1, 2020

in the newest version 0.1.0+0 you can call:

javascriptRuntime.onMessage('someChannelName',  (dynamic arguments) { 
    // here your code
}

and if in the javascript source code you call sendMessage('someChannelName', JSON.stringify([1,2,3]) your dart method will be called receiving in arguments a List with elements 1, 2 and 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants