console 3.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 85

Console #

A high-level console library.

Features #

  • Console Colors (ANSI)
  • Icons (UTF-8)
  • Keyboard Capture
  • Experimental Clipboard Support
  • Progress Bars
  • Flexible Prompts
  • Shell Prompts
  • Choosers
  • Fancy Formatting
  • Loading Bars
  • Timer (like pub's timer)
  • Fancy Trees (like the npm dependency trees)
  • Simple Unit Testing

Usage #

This library does not work in browsers (for a hopefully obvious reason).

import "package:console/console.dart";

void main() {
  // Initialize the Console. Throws an exception if advanced terminal features are not supported.
  // Use the library...

Unit Testing #

You can test the output produced by this library (and thus your own project that uses this library). Here is an example:

import "package:test/test.dart";
import "package:console/console.dart";

void main() {
  final output = new BufferConsoleAdapter();

  setUpAll(() => Console.adapter = output);

  // Clear output between test runs
  setUp(() => output.clear());

  group('base functions', () {
    test('centerCursor', () {
      expect(output.toString(), '${Console.ANSI_ESCAPE}10;40H');

3.0.0 #

First Dart 2 release.

  • Console colors (ANSI)
  • Icons (UTF-8)
  • Keyboard capture
  • Experimental clipboard support
  • Progress bars
  • Flexible prompts
  • Shell prompts
  • Choosers
  • Fancy formatting
  • Loading bars
  • Timer (like pub's timer)
  • Fancy trees (like the npm dependency trees)
  • Simple unit testing


console.dart examples #

This package comes with a number of examples to demonstrate various features.

alt_buffer.dartSwitches between normal and alternative screen buffer.
bar.dartSimple demonstration of DrawingCanvas for drawing a vertical bar.
canvas.dartShows use of ConsoleCanvas for character-based positioning.
choice.dartSelect a multiple choice option.
clock.dartSophisticated example of using DrawingCanvas to display a clock.
colors.dartSetting colored output with the TextPen class.
cube.dartDraws a 3D cube with DrawingCanvas.
cursor.dartShows use of cursor positioning operations.
dart_quiz.dartMultiple choice quiz demonstrating various console features.
demo.dartShows basic console formatting options.
drawing_canvas.dartSimple example of DrawingCanvas for a filled box.
format.dartShows use of custom formatting options for variables.
keyboard.dartTraps up and down arrow and echos to console.
loader.dartDemonstrates an indeterminate progress bar.
progress.dartDemonstrates a determinate progress bar (e.g. download)
prompt.dartShows input fields for regular and secret text entry.
shell.dartA simple REPL that echoes input text back to the console.
timer.dartExample of a timer.
window.dartExample of a full-screen window, as needed for a text editor.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  console: ^3.1.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:console/console.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on May 24, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.1
  • pana: 0.13.8-dev

Health suggestions

Fix lib/src/format.dart. (-1 points)

Analysis of lib/src/format.dart reported 2 hints:

line 131 col 28: Avoid empty catch blocks.

line 141 col 11: Use isEmpty instead of length

Fix lib/src/progress.dart. (-1 points)

Analysis of lib/src/progress.dart reported 2 hints:

line 35 col 37: DO use curly braces for all flow control structures.

line 39 col 37: DO use curly braces for all flow control structures.

Fix lib/src/clipboard.dart. (-0.50 points)

Analysis of lib/src/clipboard.dart reported 1 hint:

line 6 col 5: DO use curly braces for all flow control structures.

Fix lib/src/prompt.dart. (-0.50 points)

Analysis of lib/src/prompt.dart reported 1 hint:

line 94 col 19: Avoid empty catch blocks.

Maintenance suggestions

Package is getting outdated. (-28.22 points)

The package was last published 66 weeks ago.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
vector_math ^2.0.7 2.0.8
Dev dependencies
test ^1.0.0