4

I've been learning dart for a couple of weeks and here where I was trying to print a stack of starts (*) I discovered that there is no print method to print horizontally. It always creates a new line after it executes the print method. Here is my code:

main(List<String> args){

   for(int i = 0; i<3; i++){

      for(int k =0; k<=i; k++){
        print("*");
      }


   }

}

Here is the output:

enter image description here

Tamim
  • 181
  • 1
  • 12

1 Answers1

11

You should write directly to the stdout stream:

import 'dart:io';

main() {
  stdout.write('*');
  stdout.write('*');
}

As an aside, if you want to print the same character multiple times you can multiply strings in Dart!

print('*' * 10);

will output

**********
Danny Tuppeny
  • 40,147
  • 24
  • 151
  • 275