flexprint 0.0.1+c

Dart native js
Flutter Android iOS web

Printing tabular reports is made easier using this library. Print Headings, horizontal lines. Print to console or StringBuffer.

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.write('\n');
  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.write('\n');
  });
  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());
sb.clear();

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.

Flex #

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

Alignment #

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

Overflow #

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.

Installing #

1. Depend on it #

Add this to your package's pubspec.yaml file

dependencies:
  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';

0
likes
100
pub points
20%
popularity

Printing tabular reports is made easier using this library. Print Headings, horizontal lines. Print to console or StringBuffer.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

a.d.sudhindra@gmail.com

License

Unlicense (LICENSE)

More

Packages that depend on flexprint