fajfield_reports_flutter 0.2.0
fajfield_reports_flutter: ^0.2.0 copied to clipboard
Flutter add-on for fajfield_reports. Draws report text with Flutter's engine so every language prints, shows reports on screen, and makes PDFs and page pictures.
fajfield_reports_flutter #
Invoices, statements and multi-page reports for Flutter: designed visually, drawn by Flutter, printed offline, in every language.
Design the report in the browser with the Fajfield report designer, export the template (.fjt), and show or print it in your app with your own data. Text is measured and drawn by Flutter's own text engine, so Malayalam, Hindi, Arabic, Chinese and every other script come out correctly. Works on Android, iOS and desktop, with no internet.
This package adds Flutter to fajfield_reports, the pure Dart engine, and includes everything from it.
Above: the designer. Below: an invoice, and a 60-row stock report over two pages with its header repeated and "Page 2 of 2" filled in. Images are from the designer's preview, which uses the same layout rules as this package.
Why #
The offline report engine mobile apps never had:
- Like RDLC or Crystal Reports, but offline and cross-platform. The designer is the report builder; this package is the viewer that ships inside your app.
- Change layouts without an app release. Templates are files. Load them from assets, or from your server.
- Tables that continue across pages, with the header repeated, a totals row, and "Page x of y".
- Every language: text is shaped by Flutter, the same way your app's screens are. Use the phone's fonts, or bundle your own.
- On screen and on paper:
FjReportViewshows the real pages;render()makes a PDF. When all text is Latin, the PDF has real, selectable text; otherwise each page is a sharp picture drawn by Flutter. - Global: A4, Letter, Legal or any size, plus any locale and currency (
$1,234.50,1.234,50 €,₹1,234.50). - Any database: pass a map, or plug in sqflite, drift, Hive, Isar or REST.
- Never in the dark: every problem (a bad expression, missing data, an invalid barcode) comes back as a plain-language warning.
Install #
dependencies:
fajfield_reports_flutter: ^0.1.0
printing: ^5.11.0 # optional: the system print dialog and sharing
One import gives you everything: import 'package:fajfield_reports_flutter/fajfield_reports_flutter.dart';
Show it, print it #
final report = FjReport.fromJsonString(await rootBundle.loadString('assets/invoice.fjt'));
final data = {
'company': {'name': 'Harbour Foods Co.', 'address': '120 Harbour Road, Kochi'},
'customer': {'name': 'Fresh Mart Supermarket', 'address': '14 Marine Drive, Dubai'},
'invoice': {'no': 'INV-2026-0451', 'date': '2026-11-28', 'due': '2026-12-12'},
'items': [
{'name': 'Coconut oil 1 L', 'qty': 2, 'rate': 4.5, 'taxRate': 0.05},
{'name': 'Basmati rice 5 kg', 'qty': 1, 'rate': 18, 'taxRate': 0.05},
],
};
// On screen: the real pages, drawn by Flutter
FjReportView(report: report, data: data)
// PDF: print, share, save, email
final result = await FlutterReportRenderer().render(report, data: data);
await Printing.layoutPdf(onLayout: (_) async => result.pdf); // system print dialog
await Printing.sharePdf(bytes: result.pdf, filename: 'invoice.pdf');
// A page as a picture (thumbnails, chat apps)
final layout = await FlutterReportRenderer().layout(report, data: data);
final png = await layout.pagePng(0, dpi: 150);
PDF modes: FlutterReportRenderer(pdfMode: PdfMode.auto) (the default) uses real text when every character is Latin and no custom font is set, and page pictures otherwise. Use PdfMode.pictures to always match the screen exactly, or PdfMode.text to always have selectable text. dpi: sets the picture quality (200 by default).
Design it in the browser #
Open fajfield.com/designer/report. It's free to start and works like a desktop report builder:

- Bands: page header and footer on every page, a report header once, a body where tables grow, and a report footer after the last row (totals, notes, signatures).
- Tools: text, table, chart (bar, line, pie), picture, line, rectangle, ellipse, barcode, QR code, page number, date, signature line. Click and draw, or drag onto the page.
- Moving and editing: resize from every side, snap to grid and guides, multi-select, align and distribute, a right-click menu, copy and paste, undo.
- Properties: fonts, alignment, rotation, borders, fill, padding, "show only if" rules, number formats and table totals. Sizes in mm, cm, inches or pixels.
- Edit and View modes: View shows the real pages with sample data.
- Export → Template (.fjt): that's the file this package renders. Add it to
assets/inpubspec.yaml.

Data #
The template lists its datasets: lists (rows for tables and charts) and single records (company, customer, invoice). Pass a map with those names, or use a data source:
// sqflite, drift, Hive, Isar or anything else: one function per dataset
final source = QueryDataSource({
'invoice': () async => (await db.query('invoices', where: 'id = ?', whereArgs: [id])).first,
'items': () => db.query('invoice_lines', where: 'invoice_id = ?', whereArgs: [id]),
'company': () => Hive.box('settings').get('company'),
});
final result = await FlutterReportRenderer().render(report, source: source);
// or on screen: FjReportView(report: report, source: source)
Rows and objects are turned into plain data automatically. Objects with toJson() (drift, Isar, json_serializable) work as they are, and DateTime becomes an ISO date.
While building a screen: FlutterReportRenderer(fillMissingWithSample: true) uses the template's sample data for anything you haven't passed yet.
Expressions #
Anything in {{ }} is a field or a small, safe expression. It's parsed, never run as code.
| Write | Gives |
|---|---|
{{customer.name}} |
a field (dots reach into nested data) |
{{qty * rate * (1 + taxRate)}} |
maths: + - * / % |
{{sum(items.qty * items.rate)}} |
sum, count, avg, min, max over a list |
{{format(total, 'currency')}} |
currency, number, percent, date, datetime, 0.00, #,##0.00 |
{{qty < reorder ? 'Reorder' : 'OK'}} |
conditions; also if(a, b, c) |
{{date(today)}}, {{upper(name)}}, {{round(x, 2)}} |
dates, text, rounding |
Page {{page}} of {{pages}} |
page numbers (page header and footer) |
Number and date formats follow the template's locale and currency, set in the designer under Report → Numbers and dates.
Fonts and languages #
Text uses the font set in the designer and falls back to the device's fonts, the same way your app's screens do, so Malayalam, Hindi, Arabic and Chinese work without extra setup on most phones. To make sure, or for your brand font, bundle a font in pubspec.yaml and pass it:
FlutterReportRenderer(fontFamily: 'NotoSansMalayalam') // all text in one font
FlutterReportRenderer(fontFamilies: {'Arial': 'Inter', 'Georgia': 'Merriweather'}) // map designer fonts
FlutterReportRenderer(fontFamilyFallback: ['NotoSansMalayalam', 'NotoSansArabic'])
Text is measured and drawn by the same engine, so line wrapping and page breaks are exact.
Warnings: never in the dark #
final result = await FlutterReportRenderer().render(report, data: data);
if (result.hasWarnings) debugPrint(result.toString());
FjReportView(report: report, data: data, onLayout: (l) => setState(() => warnings = l.warnings))
ReportResult(2 pages, 48211 bytes, 63 ms, 2 warnings:
- No data for "customer". Pass it as data: {'customer': { ... }}.
- {{ qty * }}: Unfinished expression)
Problems also show in place in the PDF as [message], so you can see exactly which field failed.
How pages are laid out #
- Page header and footer on every page. The page header can skip page 1.
- Report header once, at the top of page 1.
- Body: tables add one row per item. When a row doesn't fit, the table continues on a new page with its header repeated. A row never splits, and the totals row stays with the last row.
- Groups: rows that share a value (customer, category, month) are gathered under a group header row, with a subtotal row after them. Inside a group,
{{group}}is its value and{{sum(items.amount)}}adds up only that group, so the same column totals become subtotals. Groups can be nested, sorted by name or by a total, start on a new page, or be kept on one page. - Text boxes that grow: with Can grow on, a long value (address, notes, terms) makes the box taller and pushes everything below it down. A very long text continues on the next page.
- Groups: rows that share a value (customer, category, month) are gathered under a group header row, with a subtotal row after them. Inside a group,
- Report footer after the last row. It moves to a new page if it doesn't fit.
- Page numbers are filled in last, so "Page 2 of 5" is always right.
Example app #
example/ is a Flutter app with a gallery of four reports: an invoice, the same invoice with Malayalam data, a 48-line invoice over two pages, and a stock report. Each is drawn live on the device, with print and share, an editor to change the data and render again, and a view of the template's bands and datasets.
cd example && flutter create . && flutter run
Related #
- fajfield_reports: the pure Dart engine (servers, command line), with its own small PDF writer.
- fajfield_print: labels and receipts on thermal printers (ESC/POS, TSPL, ZPL), any paper width.
- Report designer · Label designer · Developer docs
Status #
0.2.0 adds groups with subtotals and text boxes that grow. Open source under the MIT license, free for commercial apps. The designer is free to start, with advanced features in Fajfield Pro. Please report issues on GitHub with result.toString() attached.
Made by Fajfield: research and development for ERP, warehouse, POS and business data.
