1

How can I get user input of type integer in dart? I tried the following, but does not work.

int calculate(){
    int x = int.parse(stdin.readLineSync());
    int y = int.parse(stdin.readLineSync());
    return x + y;
}

I got this error:

Error: The argument type 'String?' can't be assigned to the parameter type 'String' because 'String?' is nullable and 'String' isn't.**

Beso
  • 1,176
  • 5
  • 12
  • 26
Nuh Yamin
  • 11
  • 4

0 Answers0