I'm new in world of dart and I have problem with this:

import 'dart:io';
void main() {
  print('Please your name:');
  String name = stdin.readLineSync();
  print('$name');
}
I/flutter ( 7962): Please your name:

I/flutter ( 7962): null

Every time the value is null.


Solution 1: K K Muhammed Fazil

import 'dart:io';

void main() { print('Please your name:'); String? name = stdin.readLineSync(); print('$name'); }


Solution 2: mohammad mobasher

Can you please use this code and let me know about the result :

import 'dart:convert';
import 'dart:io';

void main() {
   print('1 + 1 = ...');
   var line = stdin.readLineSync(encoding: utf8);
   print('$line');
}