Dartlings is a collection of various tiny yet useful libraries in Dart. Each dartling is a one-file library that typically doesn't span over more than 100 or 200 lines; everything else is out of scope of Dartlings.

Range (range.dart)

Range is a Collection<int> that iterates from a specified number to another (greater) specified number. Optionally, you can specify the step of iteration.

For example,

var r = new Range(0, 10);

ranges from 0 to 10 inclusive. I.e., it iterates over these numbers: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and 10.

If you specify a step,

var r = new Range(0, 10, step: 2);

you will only get 0, 2, 4, 6, 8 and 10.

Additionally, there is a function range which creates a Range with step 1. By default, the start value is inclusive and end is exclusive. I.e.,

var r = range(0, 10);

will only iterate from 0 to 9. It accepts optional inclusive parameter which controls the end value, so that

var r = range(0, 10, inclusive: true);

iterates from 0 to 10.

ANSI terminal (ansi-term.dart)

Tiny library for colored output on ANSI terminals. Only provides a handful of functions that takes a String (or any object, actually) and returns its colored variant that can be sent to the terminal.

These functions have descriptive names:

  1. black
  2. red
  3. green
  4. brown
  5. blue
  6. magenta
  7. cyan
  8. gray
  9. darkGray
  10. lightRed
  11. lightGreen
  12. yellow
  13. lightBlue
  14. lightMagenta
  15. lightCyan
  16. white

Expected usage:

print(red("this will be red"));

There's also one constant called lineBegin which is useful when writing some single-line temporary information that should be later overwritten. It only returns cursor to the beginning of the line and clears it, so it only makes sense if the temporary information didn't contain any line terminators. This can easily be achieved by using stdout.writeString from dart:io. Usage looks like:

stdout.writeString("> Running some heavy computation...");

// and later