I actually don't know how to take a integer input from the input console. Then I tried this after a little research.
My Code:
import 'dart:io';
void main() {
stdout.write("Enter a number: ");
int num1 = int.parse(stdin.readLineSync());
print(num1);
}
- But it doesn't work, showing an error message,
ERROR: The argument type 'String?' can't be assigned to the parameter type 'String' because 'String?' is nullable and 'String' isn't.
- Then finally I came to know that in dart2.12+ versions dart introduced null safety. Any suggestion to do it properly in the null safety environment.