Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

REPL for dartlang

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 to play with various APIs in dart.

like image 240
ducky Avatar asked Aug 07 '13 17:08

ducky


People also ask

Is there a dart REPL?

The Dart REPL allows you to evaluate Dart expressions and statements in an interactive shell.

How do you print on darts Hello World?

main - the entry point of our program. void - the keyword that tells the compiler that we are not returning anything from the function. print - the print function is used to print (output) whatever we put inside the parentheses.

How do you print darts?

If you simlpy want to print text to the console you can use print('Text') . But if you want to access the advanced fatures of the DevTools console you need to use the Console class from dart:html : Console. log('Text') . It supports printing on different levels (info, warn, error, debug).


2 Answers

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.

like image 169
jriggins Avatar answered Oct 06 '22 07:10

jriggins


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.

like image 35
Pixel Elephant Avatar answered Oct 06 '22 07:10

Pixel Elephant