console 3.1.0

  • Example
  • Installing
  • Versions
  • 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 packages get

Alternatively, your editor might support pub get or flutter packages 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';
Version Uploaded Documentation Archive
3.1.0 Feb 10, 2019 Go to the documentation of console 3.1.0 Download console 3.1.0 archive
3.0.0 Jun 13, 2018 Go to the documentation of console 3.0.0 Download console 3.0.0 archive
2.2.4 Aug 17, 2016 Go to the documentation of console 2.2.4 Download console 2.2.4 archive
2.2.3 Apr 22, 2015 Go to the documentation of console 2.2.3 Download console 2.2.3 archive
2.2.2 Apr 19, 2015 Go to the documentation of console 2.2.2 Download console 2.2.2 archive
2.2.0 Feb 2, 2015 Go to the documentation of console 2.2.0 Download console 2.2.0 archive
2.1.0 Dec 4, 2014 Go to the documentation of console 2.1.0 Download console 2.1.0 archive
2.0.3 Nov 30, 2014 Go to the documentation of console 2.0.3 Download console 2.0.3 archive
2.0.2 Nov 30, 2014 Go to the documentation of console 2.0.2 Download console 2.0.2 archive
2.0.1 Nov 28, 2014 Go to the documentation of console 2.0.1 Download console 2.0.1 archive

All 15 versions...

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 Apr 24, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14


Detected platforms: Flutter, other

Primary library: package:console/console.dart with components: io.

Health suggestions

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

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

line 141 col 11: Use isEmpty instead of length


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