Standard Input in Dart:
In Dart programming language, you can take standard input from the user through the console via the use of
.readLineSync() function. To take input from the console you need to import a library, named
dart:io from libraries of Dart.
About Stdin Class:
This class allows the user to read data from standard input in both synchronous and asynchronous ways. The method
readLineSync() is one of the method use to take input from user. Refer to offical doc for other method, from here.
Taking a string input from user –
Enter your name? Hello, Geek! Welcome to GeeksforGeeks!!
Taking integer value as input –
Enter your favourite number: Your favourite number is 1
Standard Output in Dart:
In dart, there are two ways to display output in the console:
- Using print statement.
- Using stdout.write() statement.
Printing Output in two different ways –
Welcome to GeeksforGeeks! // printing from print statement Welcome to GeeksforGeeks! // printing from stdout.write()
The print() statement brings the cursor to next line while stdout.write() don’t bring the cursor to the next line, it remains in the same line.
Welcome to GeeksforGeeks! // printing from stdout.write()Welcome to GeeksforGeeks! // printing from print statement
Making a simple addition program –
-----------GeeksForGeeks----------- Enter first number Enter second number Sum is 23
- How to Combine Lists in Dart?
- Basics of Numbers in Dart
- Dart - Super and This keyword
- Generators in Dart
- Dart - Classes And Objects
- Operators in Dart
- Dart - Loops
- Switch Case in Dart
- Dart - Loop Control Statements (Break and Continue)
- Dart Programming - Functions
- Instance and class methods in Dart
- Abstract Classes in Dart
- Labels in Dart
- Dart Programming - List
- Different Types of Functions in Dart
- Dart - Splitting of String
- Method Overriding in Dart
- Concept of Isolates in Dart
- Concept of Callable Classes in Dart
- Getter and Setter Methods in Dart
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.