receipt_printer 1.0.2 copy "receipt_printer: ^1.0.2" to clipboard
receipt_printer: ^1.0.2 copied to clipboard

Flutter receipt, ticket and coupon UI with printer presets, shaped paper, pull-to-tear motion, QR codes and PNG capture. Not a hardware driver.

receipt_printer #

receipt_printer for Flutter

Build polished receipts, tickets, coupons, and printer previews in Flutter. The package includes nine presets, shaped paper, QR and Code 128 support, pull-to-tear interaction, confetti, sound, and PNG capture.

receipt_printer is a UI package. It does not communicate with physical printers or process payments.

Live Gallery · pub.flutter-io.cn · Usage guide · API documentation

Install #

Install the latest stable release from pub.flutter-io.cn:

flutter pub add receipt_printer

Or add version 1.0.2 directly to pubspec.yaml:

dependencies:
  receipt_printer: ^1.0.2

Then import the package:

import 'package:receipt_printer/receipt_printer.dart';

Requires Dart 3.13 and Flutter 3.47 or newer.

Quick start #

ReceiptPrinter(
  preset: ReceiptPrinterPreset.classicThermal,
  child: ReceiptView(
    receipt: Receipt(
      title: 'Coffee Shop',
      items: const [
        ReceiptItem(title: 'Latte', quantityMillis: 2000, unitPrice: 450),
      ],
    ),
    formatter: ReceiptFormatter(currency: 'USD'),
  ),
)

Prices use integer minor units, so 450 means $4.50 when the formatter uses two decimal places. The package calculates the item subtotal; taxes, discounts, and final totals remain under your control.

Presets #

Every preset includes a printer shell, paper style, typography, sample receipt, and interaction defaults. Use a preset as-is or override only what you need.

Classic Thermal Modern POS Counter
Classic Thermal preset Modern preset POS Counter preset
classicThermal modern posCounter
Cinema Ticket Discount Token Kitchen Order
Cinema Ticket preset Discount Token preset Kitchen Order preset
cinemaTicket discountToken kitchenOrder
Mobile Terminal Parking Pass Artisan Bakery
Mobile Terminal preset Parking Pass preset Artisan Bakery preset
mobileTerminal parkingPass artisanBakery

Select one with ReceiptPrinterPreset.<name>:

ReceiptPrinter(
  preset: ReceiptPrinterPreset.cinemaTicket,
  child: ReceiptView(
    receipt: ReceiptPrinterPreset.cinemaTicket.receipt,
  ),
)

Customize a preset #

Use copyWith to retain the preset defaults:

final preset = ReceiptPrinterPreset.modern;

ReceiptPrinter(
  preset: preset,
  paper: preset.paper.copyWith(
    bottomEdge: const ReceiptPaperEdge(
      shape: ReceiptPaperEdgeShape.deckled,
    ),
  ),
  receiptTheme: preset.theme.copyWith(
    backgroundColor: const Color(0xFFFFF3C4),
  ),
  child: ReceiptView(
    receipt: preset.receipt.copyWith(title: 'My café'),
    formatter: ReceiptFormatter(currency: 'USD'),
  ),
)
  • style changes the printer housing.
  • paper changes the sheet and its edges.
  • receiptTheme changes paper color, ink, and typography.
  • interaction changes pull-to-tear behavior.

Pull to tear #

final controller = ReceiptPrinterController();

ReceiptPrinter(
  controller: controller,
  preset: ReceiptPrinterPreset.classicThermal,
  interaction: ReceiptRipConfig.presets['snappy'],
  child: ReceiptView(receipt: receipt),
)

Users can drag the receipt or use Enter and Space. You can also call controller.ripReceipt() and controller.resetReceipt(). Reduced-motion preferences are respected automatically.

Capture a PNG #

After the widget has painted:

final receiptPng = await controller.captureReceipt();
final previewPng = await controller.capturePrinterPreview();

Capture uses explicit pixel and dimension limits. Dispose the controller when its owner is removed.

Optional effects #

  • ReceiptConfettiConfig adds confetti at separation.
  • ReceiptAudioConfig(enabled: true) enables the bundled web tear sound.
  • Native audio stays app-owned through ReceiptAudioConfig.onPlay.

Audio is off by default, and reduced motion suppresses particle movement.

RTL and long receipts #

Use textDirection: TextDirection.rtl and a Persian ReceiptFormatter for RTL content. The bundled Vazirmatn font supports the default Persian presets.

Receipts use their natural content height. Put the printer inside your page's outer scroll view for long content. Use ReceiptView.scrollable only when you need an explicitly bounded lazy viewport.

The interactive Gallery lets you edit printer, paper, receipt, and interaction settings and copy the matching public Dart API.

Run it locally with:

cd example
flutter pub get --enforce-lockfile
flutter run -d chrome

Gallery edits stay in the browser session and receipt content is not uploaded.

Documentation #

License #

The package is available under the MIT License. Bundled fonts retain their OFL notices.

4
likes
160
points
159
downloads
screenshot

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Flutter receipt, ticket and coupon UI with printer presets, shaped paper, pull-to-tear motion, QR codes and PNG capture. Not a hardware driver.

Repository (GitHub)
View/report issues
Contributing

Topics

#receipt #printer #flutter-ui #pos #thermal-printer

License

MIT (license)

Dependencies

barcode_widget, flutter, web

More

Packages that depend on receipt_printer