搜尋套件、儲存庫與 APP 分類

套件詳情v1.0.2

quick_print

一個全面的 Flutter 套件,用於在不同平台和設備上處理 PDF 列印,支援多種列印機類型,包括 ESC/POS、Sunmi、藍牙、USB 和系統列印機。

AndroidiOSmacOSWindowsLinux
近 30 天下載
34
喜歡數
43
Pub 分數
120

安裝套件

flutter pub add quick_print

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Quick Print 是一個多功能的 Flutter 套件,專為在 Android、iOS、macOS、Windows 和 Linux 等多個平台實現無縫 PDF 列印而設計。它支援多種列印機,如 ESC/POS、Sunmi、藍牙、USB 和系統列印機,讓開發者能有效產生並傳送列印工作。此套件透過一致的 API 與強大的裝置相容性,簡化跨平台列印。非常適合需要可靠列印功能的零售、POS 及文件管理應用。

適用情境

  • 零售收據打印
  • POS系統整合
  • 文件批量列印
  • 移動應用報告
  • 跨平台列印

主要特色

  • 多平台支援
  • ESC/POS 與藍牙列印機相容性
  • PDF生成和打印
  • USB 和系統印表機整合
  • 跨裝置列印作業處理

適合對象

  • POS應用開發者
  • 零售軟件團隊
  • 需要列印的行動應用開發者
  • 文件自動化專案
  • 跨平台列印解決方案

使用建議

  • 需要平台特定的設定
  • 高級功能的文件有限
  • 藍牙配對可能需要使用者介入
  • 目標作業系統上的印表機驅動程式可用性
  • 建議在多個設備上進行測試

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Quick Print

A comprehensive Flutter package for handling PDF printing across different platforms and devices. This package provides a unified interface for printing PDFs using various printer types, including ESC/POS, Sunmi, Bluetooth, USB, and system printers.

pub package likes popularity

Features

  • 🖨️ Multi-printer Support
    • Sunmi printer support for Android devices
    • Bluetooth printer integration (including BLE)
    • USB printer compatibility
    • Desktop system printer support
    • Mobile device printing
  • 🖼️ Image Printing Support
    • Print images (Uint8List) directly to any supported printer
  • 📄 Paper Size Options
    • 80mm paper width (POS printers)
    • 58mm paper width (Thermal printers)
    • A4 paper size
  • 🎯 Platform Support
    • Android
    • iOS
    • Windows
    • Linux
    • macOS
  • 🔍 Printer Discovery
    • Discover Bluetooth, BLE, USB, and desktop printers
    • Unified API for managing discovered printers
  • 🛠️ Error Handling
    • Custom exceptions for invalid files, unconnected devices, and unsupported operations

Getting Started

Add this to your package's pubspec.yaml file:

dependencies:
  quick_print: <LASTEST_VERSION>

Then run:

flutter pub get

Usage

Basic Usage
import 'package:quick_print/quick_print.dart';

// Create a printer instance
final printer = QuickPrint(PrinterDeviceType.mobile);

// Print a PDF file
await printer.instance.print(
  path: 'assets/document.pdf',
  paperSize: PaperSize.a4,
);

// Print an image (as Uint8List)
final imageBytes = await File('assets/image.png').readAsBytes();
await printer.instance.printImage(
  bytes: imageBytes,
  paperSize: PaperSize.a4,
);
Printer Discovery

The PrinterDiscoveryService class allows you to discover printers on various platforms.

import 'package:quick_print/quick_print.dart';

final discoveryService = PrinterDiscoveryService();

// Initialize the service (required for BLE on Windows)
await discoveryService.initialize();

// Discover printers
await discoveryService.discoverDevices();

// List discovered printers
final printers = discoveryService.printerDevicesList;
printers.forEach((printer) {
  print('Discovered printer: ${printer.name}');
});

// Dispose of the service when done
discoveryService.dispose();
Bluetooth Printer
import 'package:quick_print/quick_print.dart';

// Create a Bluetooth printer model
final bluetoothModel = BluetoothPrinterModel(
  name: 'Thermal Printer',
  address: '00:11:22:33:44:55',
  isBle: false,
);

// Create a printer instance
final printer = QuickPrint(PrinterDeviceType.bluetooth);

// Print with the Bluetooth printer
await printer.instance.print(
  path: 'assets/receipt.pdf',
  paperSize: PaperSize.mm80,
  model: bluetoothModel,
);
USB Printer
import 'package:quick_print/quick_print.dart';

// Create a USB printer model
final usbModel = UsbPrinterModel(
  name: 'POS-58',
  productId: '0x0483',
  vendorId: '0x5740',
);

// Create a printer instance
final printer = QuickPrint(PrinterDeviceType.usb);

// Print with the USB printer
await printer.instance.print(
  path: 'assets/receipt.pdf',
  paperSize: PaperSize.mm58,
  model: usbModel,
);

Platform-specific Setup

Android

Add the following permissions to your AndroidManifest.xml:

<!-- For Bluetooth printers -->
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>

<!-- For USB printers -->
<uses-feature android:name="android.hardware.usb.host"/>
iOS

Add the following to your Info.plist:

<key>UISupportedExternalAccessoryProtocols</key>
<array>
    <string>com.printer.protocol</string>
</array>

<!-- For Bluetooth printers -->
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Need BT access for printing</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>Need BT access for printing</string>
macOS

Add the following entitlements to your app:

com.apple.security.print
com.apple.security.device.usb
com.apple.security.device.bluetooth

Error Handling

The package uses custom exceptions for error handling:

  • PrinterException: General printer errors
  • InvalidFileException: Errors related to invalid files
  • InvalidTypeException: Errors for invalid printer models
  • UnConnectedDeviceException: Errors for unconnected devices

Example:

try {
  await printer.instance.print(
    path: 'assets/document.pdf',
    paperSize: PaperSize.a4,
  );
} on PrinterException catch (e) {
  print('Printing failed: ${e.message}');
  if (e.cause != null) {
    print('Cause: ${e.cause}');
  }
}

Additional Information

  • Documentation: Full API documentation is available here.
  • Examples: Check the example directory for more detailed examples.
  • Issues: File issues, bugs, or feature requests here.
  • Contributing: See CONTRIBUTING.md for guidelines.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For support and questions, please:

  1. Check the FAQ section
  2. Search for existing issues
  3. Create a new issue if needed

Acknowledgments

  • Thanks to all contributors who have helped make this package better
  • Special thanks to the Flutter and Dart teams for their amazing work

/// Printer implementation for USB-connected printers. class UsbPrinter extends IConnectionPrinter { }

所屬分類

依賴

依賴清單 10 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。