User input in Dart
Published in
Apr 8, 2024
Lesson#13
import 'dart:io';
void main() {
print("Enter you name: ");
String? name;
name = stdin.readLineSync();
print("Hello $name");
}
Example-2
import 'dart:io';
void main() {
int a,b,c;
print("Enter a number-1: ");
a = int.parse(stdin.readLineSync() ?? '0');
print("Enter a number-2: ");
b = int.parse(stdin.readLineSync() ?? '0');
c = a + b;
print("The sume of $a and $b is $c");
}
/* Output
Enter a number-1:
12
Enter a number-2:
32
The sume of 12 and 32 is 44
*/
What’s next?