consola 0.1.0 copy "consola: ^0.1.0" to clipboard
consola: ^0.1.0 copied to clipboard

A utility library to help developing command-line applications in Dart. Provides screen manipulation, ANSI escape codes, and more.

example/consola_example.dart

import 'dart:io';

import 'package:consola/consola.dart';

void main() {
  Console.clearScreen();
  Console.writeLine('Hello, world!');
  Console.writeLine('Pos: ${Console.getCursorPosition()}');
  Console.writeLine('Whats up?', foregroundColor: SimpleColor.yellow);
  Console.write('Goodbye!', backgroundColor: SimpleColor.red);
  Console.writeLine('');
  Console.writeLine('Hello');

  final progressBar1 = ProgressBar.atPosition(
    total: 50,
    console: Console.instance,
    position: ConsoleCoordinate(1, 8),
    head: 'Progress A: ',
    tailBuilder: (_, __, percent) => ' ${percent.toStringAsFixed(0)}%',
  );

  final progressBar2 = ProgressBar.atPosition(
    total: 50,
    console: Console.instance,
    position: ConsoleCoordinate(1, 9),
    head: 'Progress B: ',
    tailBuilder: (_, __, percent) => ' ${percent.toStringAsFixed(0)}%',
  );

  print('Position: ${progressBar1.position}');

  for (var i = 0; i <= 50; i++) {
    progressBar1.current = i;
    Console.draw(progressBar1);
    progressBar2.current = i;
    Console.draw(progressBar2);
    sleep(Duration(milliseconds: 50));
  }

  sleep(Duration(seconds: 1));

  Console.clearScreen();

  Console.writeLine('Hello, world again!', foregroundColor: SimpleColor.green);

  final result = Console.readLine(prompt: 'What is your name? ');
  Console.writeLine('Hello, $result!');

  final int? age = Console.readInt(prompt: 'What is your age? ');
  Console.writeLine('You are $age years old.');
}
0
likes
140
pub points
0%
popularity

Publisher

verified publishertienisto.com

A utility library to help developing command-line applications in Dart. Provides screen manipulation, ANSI escape codes, and more.

Repository (GitHub)
View/report issues

Topics

#console #ansi #cli #terminal

Documentation

API reference

License

MIT (LICENSE)

Dependencies

meta

More

Packages that depend on consola