REPL for dartlang

后端 未结 4 1730
独厮守ぢ
独厮守ぢ 2021-01-07 19:29

Is there a REPL for Dart to experiment with?

I tried inputing dart code in devtools in Dartium and that also didn\'t work.

So I couldn\'t find an easy way t

相关标签:
4条回答
  • 2021-01-07 19:36

    The correct answer is https://dartpad.dev/

    That site didn't exist when the other answers were posted in 2013, but you've stumbled on this post after 2020. And now you know. https://dartpad.dev allows you to create and share new Dart snippets and even put them in a Flutter app running online. Very, very cool!

    0 讨论(0)
  • 2021-01-07 19:42

    There is an announcement about REPL for Dartium - see Nathanial's comment below. There are plans for Smalltalk like super-REPL. Here is what Gilad Bracha (member of the Dart team at Google) wrote on this subject in Is there a REPL or console for Dart:

    "I don't see this as a language question at all. It is a matter of tooling and reflective library support. With proper mirror builder APIs, building a REPL would be trivial. As it sands right now, it can be quite challenging. And of course, REPL is not the ultimate goal - there are more advanced interactive tools, like workspaces in Smalltalk/Self/Newspeak, where you not only evaluate things interactively at some top level, but can inspect the resulting objects, evaluate within the scope of an individual declaration or object etc. I am sure we will get there in time - and i much prefer sooner than later."

    0 讨论(0)
  • 2021-01-07 19:46

    Though it is not really a REPL, you may find the Try Dart online tool useful for playing around. It's a bit slow, since it is actually compiling the Dart code to JavaScript in order to have it work within the browser.

    There is also a console that someone built, which is probably better if you're looking for a real REPL, but it requires a bit of setup.

    0 讨论(0)
  • 2021-01-07 19:56

    I tried inputing dart code in devtools in Dartium and that also didn't work.

    I'm very new to Dart, but something I came across was that you CAN evaluate code in Dartium. In order to do so, you must first load a page with Dart code in it and then toggle this selector in the console from "javascript page context" to one that references a Dart package or Dart code.

    enter image description here

    Once you do that you should be able to execute Dart in the console:

    enter image description here

    As a VIM user, I hardly have to open the Dart Editor now :). I should also mention that breakpoints, hovering over stepped into code to get variable details, navigating the call stack, and some level of intellisense in the console also work. I couldn't get conditional breakpoints to work, though.

    0 讨论(0)
提交回复
热议问题