Reputation: 43
Im trying to follow tutorials from "Dart for Absolute Beginner" book and from dartlang https://www.dartlang.org/tutorials/dart-vm/cmdline "stdin" examples to accept keyboard input however dartpad will show 'uncaught' for every examples i tried.
Sample code:
import 'dart.io'
void main() {
stdout.writeln('Type something');
String input = stdin.readLineSync();
stdout.writeln('You typed: $input');
}
Can somebody point me to what I should add ? A try and catch block ? How do I do that or get to that ? I am only on page 41 for the "Dart for Absolutely Beginner" book so don;t expect me to know much.
Upvotes: 4
Views: 8888
Reputation: 158
you can use that website it's support dart:io https://replit.com/languages/dart
Upvotes: 0
Reputation: 657018
DartPad transpiles Dart to JavaScript before it can execute the code.
dart:io
is limited to console applications.
dart:html
provides abstraction of the API available in the browser, but there is no equivalent to stdin
or readLine
in the browser.
Upvotes: 8