FlexPrint - A Dart Library for console printing using flex layout

Console Printing tabular reports is made easier using this library. Flexprint allows great flexibilty to the programmer to specify the table's appearance.

inport 'package:flexprint/flexprint.dart'

final fp = FlexPrint();
  fp.horizontalLine(doubleLine: true);
  fp.write('Customer Name', flex: 3);
  fp.write('Amount Due', flex: 2, alignment: Alignment.end);
  fp.write('Invoice Details', flex: 3);
  fp.write('Status', flex: 2, alignment: Alignment.center);
  fp.horizontalLine(doubleLine: true);
  customers.forEach((row) {
    fp.write(row.name, flex: 3);
    fp.write(row.amountDue.toString(), flex: 2, alignment: Alignment.end);
    fp.write(row.invoiceDetail, flex: 3);
    fp.write(row.status, flex: 2, alignment: Alignment.center);
  fp.horizontalLine(char: '_');

Please see the code in example This will generate the following console output:

Customer Name                Amount Due Invoice Details              Status
John Doe & Co                   6789.12 Inv No 66987 of 06/15/20       Due
M D Rao & Co                   16789.12 Inv No 66989-92 of 08/12    Paid 10/05

FlexPrint can print either to the console printer or to StringBuffer.

final fp = FlexPrint(useStringBuffer: true);


final sb = fp.stringBuffer;

## email the report or whatever
sendMail('doe@anon.com', sub: 'Activity report', body: sb.toString());

Line Width, Padding, Overflow

The default line width is 80 characters long, padding is 1 character, Overflow is truncated. Any or all of these can be set through the construtor.

Adding Columns

Any number of columns may be added through the write() method. The first column with a newline ('\n') character outputs that row and subsequent writes add to the next row.


Each column has a default flex factor of 1. You may specify any flex number.


You may specify that a column be justified left - Alignment.start, center - Alignment.Center, right Alignment,end


If you set overflow to Overflow,wrap, FlexPrint will wrap text within the column, otherwise the overflow text is truncated to the width of column.


1. Depend on it

Add this to your package's pubspec.yaml file

  flexprint: ^0.0.1+b

2. Install it

With pub:

$ pub get

With flutter:

$ flutter pub get

3. Import it

In your Dart or Flutter code, use:

import 'package:flexprint/flexprint.dart';


Format reports using this lightweight Dart Library. Supports Dart and Flutter. Flutter applications may want to use the StreamBuffer option.