pos_flutter_printer

A Flutter plugin to print structured receipts (with text, images, QR codes, font styles, alignment, and margins) on Bluetooth POS printers.

🚀 Features

  • Print styled text with custom font, size, and alignment
  • Print base64 images with align and width options
  • Print QR codes with alignment and size
  • Margin control (top and bottom)
  • Supports Android Bluetooth POS printers
  • Fully customizable via Flutter JSON-based structure

📦 Installation

Add this plugin in your pubspec.yaml:

dependencies:
  pos_flutter_printer: ^1.0.0

🛠 Usage

1. Import the plugin

import 'package:pos_flutter_printer/pos_flutter_printer.dart';

2. Use it in your code

final lines = [
  {
    "text": "THANK YOU",
    "align": "center",
    "size": 4,
    "font": "Roboto-Regular.ttf",
    "bold": true
  },
  {
    "text": "Pawan Kumar",
    "align": "center",
    "bold": false,
    "size": 3,
    "font": "Roboto-Regular.ttf",
  },
  {
    "image": "BASE64_IMAGE_STRING",
    "width": 250,
    "align": "center"
  },
  {
    "qr": "https://4brains.in",
    "width": 200,
    "align": "center"
  }
];

final result = await PosFlutterPrinter.printReceipt(
  lines: lines,
  topMargin: 30,
  bottomMargin: 60,
);

print("Result: \$result");

Fonts

Place your font file (e.g. Roboto-Regular.ttf) in:

android/src/main/assets/fonts/

Manifest Permissions

In your plugin's AndroidManifest.xml:

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

🧩 Parameters for Each Line

Key Type Description
text String Text to print
size int Font size scale (1 to 4)
bold bool Bold text
align String "left", "center", or "right"
font String Font filename in assets/fonts
image String Base64 image data
qr String Text/URL for QR code
width int Image or QR size in pixels
marginTop int Optional top margin before this line

📋 License

MIT License. Created by 4Brains Technologies.