Simple command-line app I/O in Dart

Is there a way of taking single character (integer) keyboard inputs from the user and storing them to a variable in a Dart command-line app? I've tried something like:

Stream cmdLine = stdin
  .transform(new StringDecoder())
  .transform(new LineTransformer());

StreamSubscription cmdSubscription = cmdLine.listen(
  (line) => (choice = line);

In an attempt to store a keyboard input into the variable 'choice' and many slight variations of this code but can't get it to work.


Currently you can only read a whole line at a time - i.e. once enter is pressed.

Star this issue.


The readLine() function waits for a line of input from a user and returns it as a string.

import 'dart:async';
import 'dart:io';

main() {
    print('1 + 1 = ...');
    readLine().then((line) {
        print(line.trim() == '2' ? 'Yup!' : 'Nope :(');

Future<String> readLine() {
    var completer = new Completer<String>();

    var input = stdin
        .transform(new StringDecoder())
        .transform(new LineTransformer());

    var subs;
    subs = input.listen((line) {

    return completer.future;



  • Console application - StringDecoder stdin
  • shared_from_this throws bad_weak_ptr with boost::asio
  • Count occurrences Prolog
  • Is there any other advantage to using '_svn' directories instead of '.svn' in a
  • Relative CSS urls in Webpack
  • Javascript iPhone selection
  • psycopg2 and SQL injection security
  • Why call session not working? (codeigniter 3)
  • XslTransform with xml-stylesheet
  • FParsec only parses expr between parentheses
  • Difference between Echo[Special Character]
  • SonataAdmin - sonata_type_choice_field_mask
  • Is the integer width relevant in bitfield declaration?
  • Laravel nested foreach by 2 different Models
  • Sampling unique column indexes for each row of a numpy array
  • Fresh Rails 4 app is not recognizing `rails` commands, insists that I use `rails new`
  • minOccurs and maxOccurs on elements inside xsd:choice
  • Python Pandas global vs passed variable
  • R mlogit on my data giving error 'system is computationally singular?
  • When is InputStream.available() useful?
  • ColdFusion - DateTime Format with GMT offset
  • Sharepoint change Content Type in Sharepoint Designer using workflow
  • Connection between Node.JS and PHP via UNIX Socket - EPIPE write error
  • Change colour of vertices after they are uploaded using a VBO
  • Radio button show hover between two radio button using jquery
  • Thread Synchronization with IntentService
  • Django Rest Framework: getting lists from query_params without request.getlist
  • Sails.js to client using sails.sockets.join and sails.sockets.broadcast doesn't return info to
  • Simple command-line app I/O in Dart
  • Can't configure nginx as a proxy for tomcat with context path
  • What is wrong in my MVC implementation?
  • Unix Network Programming Clarification
  • How to handle AllServersUnavailable Exception
  • Busy indicator not showing up in wpf window [duplicate]
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?