Search code examples
flutterdartstdoutstdin

Standard Input and Output operations in flutter


What is the approach for using standard i/o in flutter? I've tried the following code but there is no render and build gets stuck.

import 'dart:io';

void main() {
 stdout.writeln("Enter value");
 String str = stdin.readLineSync();
// user inputs value
 print(str);
}

The documentation says


> To read text synchronously from the command line (the program blocks
> waiting for user to type information):

String inputText = stdin.readLineSync();

But how to appropriately input values? Because flutter run doesn't let me input values.


Solution

  • Actually, what you're doing doesn't require you to use Flutter. You can run it using Dart. The thing is that Flutter is meant for application development for Android, iOS, Web and other such platforms. It isn't created for such applications that you desire.