In every programming language we can input value by two method either it is static means we can store value in variable when we write code and this value can not change during run time or we can get input from user which means when code is running at that time compiler ask to user to enter input and then compiler do further process.
In dart we can use one line code for getting user input.
Here , I am writing syntax and one example of how we can take unput from user.
Using this we can get input from user either value is String , Int , double , we can get type of input from user.
Using this we do not need to set pre-defined value of variable.
But , remember that there is small change in syntax between String and int, double which I have mentioned below.
Syntax
String? name = stdin.readLineSync(); (for String)
int? num= int.parse(stdin.readLineSync()!); (for Int)
double? num = double.parse(stdin.readLineSync()!); (for Double)
void main() { print("Enter Name : "); String? name = stdin.readLineSync(); print("You Enter $name" ); }
ย