Home > Mobile >  Dart, stdin.readLineSync();
Dart, stdin.readLineSync();

Time:10-19

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.

CodePudding user response:

import 'dart:io';

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

CodePudding user response:

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');
}
  • Related