User input in Dart

Haider Ali
Complete Flutter Guide
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
*/
User Input

What’s next?

--

--