0

I am new to Dart and was wondering if I am able to change the output of stdin.readLineSync() in the terminal. Here is an example of what I want:

import "dart:io";
void    main()
{
    print("Insert your name: ");
    String str = stdin.readLineSync()!;
    print("Your name is $str");
}

Output

Insert your name: 
Max   
Your name is Max

Desired output:

Insert your name: Max
Your name is Max

1 Answers1

1

You can use stdout.write to print to the console without a newline.

import "dart:io";
void    main()
{
    stdout.write("Insert your name: ");
    String str = stdin.readLineSync()!;
    print("Your name is $str");
}

Related: print() without a newline in Dart?

Samathingamajig
  • 11,839
  • 3
  • 12
  • 34