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

How do I execute Dynamically (like Eval) in Dart? #36989

smile2014 opened this issue May 17, 2019 · 2 comments


Copy link

commented May 17, 2019

var doAdd = new Function("iNum", "alert(iNum + 10)");
doAdd(10);----> 20


This comment has been minimized.

Copy link

commented May 17, 2019

Dart does not allow you to create code at run-time.

What problem are you trying to solve?

There are workarounds when you are running on the VM and has access to isolates. You can create a new library with a main function, encode the source code as a data: URI and spawn it as a new isolate, but that will not allow you to create a new functions in the current isolate. You'll have to communicate with the new code using isolate port communication.

In general, I'd recommend trying something else. It is often possible to get the effect of generating code by just combining first-class function values, but that obviously depends on the problem at hand.

@lrhn lrhn added the type-question label May 17, 2019


This comment has been minimized.

Copy link

commented May 19, 2019

I dynamically render the form through the json data given by the backend. The disabled corresponds to a piece of javascript, similar to angular ngx-formly expression

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.