Documentation Index
Fetch the complete documentation index at: https://mintlify.com/NormandoRamirezDelgado/6C-Febrero-2026/llms.txt
Use this file to discover all available pages before exploring further.
Introduction
In Dart, you can read user input from the console using thestdin object from the dart:io library. This is essential for creating interactive command-line applications.
Reading String Input
To read text input from the user, usestdin.readLineSync():
The return type is
String? (nullable) because readLineSync() can return null if the input stream is closed or if an error occurs.Reading Numeric Input
To read numeric values, you need to:Reading Integers
Complete Example
Here’s a complete program that demonstrates reading both string and numeric input:Key Points
Import Required
Always import
dart:io to access stdinNullable by Default
readLineSync() returns String? which must be handledParse Numbers
Use
int.parse() or double.parse() for numeric inputNull Assertion
Use
! operator when you’re sure the input won’t be null