Skip to content

VarunS2002/Dart-interactive_print

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

Dart-interactive_print

A Dart library to simulate print() without adding a trailing newline for both Native and Web.

Latest_Release License: GPL v3

Usage

dependencies:
  interactive_print: ^1.0.0

A simple usage example:

import 'package:interactive_print/interactive_print.dart';

void main() {
  write('Hello');
  writeln('There');
  write('General Kenobi');
  writeln('.');
}

Objective of this package

The print() function in Dart always adds a newline to the end, so you cannot print character by character. This is particularly useful if you want to have a delay between printing characters or if you want to construct a line dynamically using characters at runtime. Dart has 2 supported platforms namely Native and Web. On Native, you can use stdout.write() to print without a newline, however this breaks support for Web as this function is not supported. Web also doesn't have any method to print without a newline but this behaviour can be simulated like this. This Dart library provides its own write() and writeln() function which will dynamically use stdout.write() or the console.log() trick based on the platform you are running on. More discussion here.

Note

  • May not work correctly if you run your application in debug mode.

  • If you face any issue or have suggestions then feel free to open an issue on GitHub.

  • Majority of the code was contributed by lrhn.

About

A Dart library to simulate print() without adding a trailing newline for both Native and Web.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages