colorize 2.0.0

Colorize #

Colorize console output in dart console apps!

Install #

Add dependency to your pubspec.yaml:

colorize: any

Run

pub get

Usage #

Import package:

import 'package:colorize/colorize.dart';

You have two way to colorize your string:

  • use class Colorize
  • use top-level function color()

Use Colorize

For colorize string with Colorize class you should create object of type Colorize:

Colorize string = new Colorize("This is my string!");

Then you can call methods of Colorize.

Text color

  • default()
  • black()
  • red()
  • green()
  • yellow()
  • blue()
  • magenta()
  • cyan()
  • lightGray()
  • darkGray()
  • lightRed()
  • lightGreen()
  • lightYellow()
  • lightBlue()
  • lightMagenta()
  • lightCyan()
  • white()

Background color

  • bgDefault()
  • bgBlack()
  • bgRed()
  • bgGreen()
  • bgYellow()
  • bgBlue()
  • bgMagenta()
  • bgCyan()
  • bgLightGray()
  • bgDarkGray()
  • bgLightRed()
  • bgLightGreen()
  • bgLightYellow()
  • bgLightBlue()
  • bgLightMagenta()
  • bgLightCyan()
  • bgWhite()

Formatting

  • reset()
  • bold()
  • dark()
  • italic()
  • underline()
  • blink()
  • reverse()
  • concealed()

After apply styles to string you can print it to console:

print(string);

Use top-level function color()

Top-level function color apply one required parameter - String text. It is text, that would be print on console.

Also top-level function color has seven named parameters:

  • Styles front - name of front color (you can also use the constants of class Styles). Default value is ''.
  • Styles back: name of background color (you can also use the constants of class Styles). Default value is ''.
  • bool isUnderline - default value is false.
  • bool isBold - default value is false.
  • bool isDark - default value is false.
  • bool isItalic - default value is false.
  • bool isReverse - default value is false.

Example of usage

color("Bold Italic Underline", front: Styles.RED, isBold: true, isItalic: true, isUnderline: true);

Enum Styles

Enum Styles contains all styles which you can pass to Colorize.applyState method;

Use this package as a library

1. Depend on it

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


dependencies:
  colorize: ^2.0.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:colorize/colorize.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
85
Health:
Code health derived from static analysis. [more]
96
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
27
Overall:
Weighted score of the above. [more]
77
Learn more about scoring.

We analyzed this package on Nov 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:colorize/colorize.dart.

Health issues and suggestions

Document public APIs. (-1 points)

96 out of 96 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/src/color.dart. (-2.96 points)

Analysis of lib/src/color.dart reported 6 hints, including:

line 6 col 21: Use = to separate a named parameter from its default value.

line 7 col 16: Use = to separate a named parameter from its default value.

line 8 col 16: Use = to separate a named parameter from its default value.

line 9 col 18: Use = to separate a named parameter from its default value.

line 10 col 19: Use = to separate a named parameter from its default value.

Format lib/colorize.dart.

Run dartfmt to format lib/colorize.dart.

Format lib/src/colorize.dart.

Run dartfmt to format lib/src/colorize.dart.

Maintenance issues and suggestions

Provide a file named CHANGELOG.md. (-20 points)

Changelog entries help developers follow the progress of your package. See the example generated by stagehand.

Package is getting outdated. (-21.37 points)

The package was last published 63 weeks ago.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and colorize.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Update README.md. (-2 points)

1 image link is insecure (e.g. http://i.imgur.com/BaxDbw9.png), use https URLs instead.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0