パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v1.2.4

flutter_pos_printer_platform_image_3

Android、iOS、Windows などの異なるプラットフォームおよび Bluetooth と BLE、TCP および USB などのさまざまなインターフェースでプリンターに ESC コマンドを送信するための Flutter プラグイン

AndroidiOSWindows
30日間ダウンロード
1980
いいね数
58
Pub ポイント
110

パッケージをインストール

flutter pub add flutter_pos_printer_platform_image_3

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Android、iOS、Windows上でBluetooth、BLE、TCP、USBインターフェースを介して、さまざまなプリンタにESC/POSコマンドを使用したクロスプラットフォーム印刷を可能にするFlutterプラグインです。レシートプリンタの小売・ホスピタリティ・販売ポイントシステムに最適な、生のプリンタコマンドを送信するための一貫したAPIを提供します。プラグインはプラットフォーム固有の実装を抽象化し、異なるデバイスおよびオペレーティングシステム間での統合を簡素化します。

用途

  • POSシステムにおける領収書印刷
  • BluetoothまたはUSBによるモバイル印刷
  • クロスプラットフォーム印刷アプリケーション
  • 小売およびレストランの注文処理
  • TCP/IPを介したリモート印刷

主な機能

  • 複数のプラットフォーム (Android、iOS、Windows) をサポートしています
  • ESC/POS コマンドの送信処理
  • Bluetooth、BLE、TCP、USBに対応
  • プラットフォーム間での統合 API
  • 軽量かつ効率的

適している対象

  • POSアプリを開発する開発者
  • 複数デバイス印刷が必要な事業者
  • 信頼性のある受領印刷を必要とするアプリケーション
  • クロスプラットフォームモバイルソリューション
  • ESC/POSプリンタと連携するハードウェア統合担当者

注意事項

  • 互換性のあるESC/POSプリンターが必要です
  • プラットフォーム固有の設定が必要になる場合があります
  • ESC/POS コマンドセットに制限
  • Bluetoothのペアリングは手動で処理する必要があります
  • 組み込みの印刷プレビューまたはフォーマットツールなし

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

flutter_pos_printer_platform

Pub Version

Notice: This library was initially forked from arthas1888 in order to use it in a flutter project that use both image v4 and image v3 dart libraries. And since then, the library received many bug fixes after the original library was discontinued.


A library to discover printers, and send printer commands.

This library allows to print esc commands to printers in different platforms such as android, ios, windows and different interfaces as Bluetooth and BLE, USB and Wifi/Ethernet

Inspired by flutter_pos_printer.

Main Features

  • Android, iOS and Windows support
  • Scan for bluetooth devices
  • Send raw List<int> bytes data to a device, review this library to generate ESC/POS commands flutter_esc_pos_utils.

Features

Android iOS Windows Description
USB interface :white_check_mark: :white_square_button: :white_check_mark: Allows connection with usb devices.
Bluetooth classic interface :white_check_mark: :white_square_button: :white_square_button: Allows connection with classic bt devices.
Bluetooth low energy (BLE) interface :white_check_mark: :white_check_mark: :white_square_button: Allows connection with bt BLE devices.
Net (ethernet/wifi) interface :white_check_mark: :white_check_mark: :white_check_mark: Allows connection with network devices.
scan :white_check_mark: :white_check_mark: :white_check_mark: Starts a scan for only Bluetooth devices or network devices(Android/iOS).
connect :white_check_mark: :white_check_mark: :white_check_mark: Establishes a connection to the device.
disconnect :white_check_mark: :white_check_mark: :white_check_mark: Cancels an active or pending connection to the device.
state :white_check_mark: :white_check_mark: :white_check_mark: Stream of state changes for the Bluetooth Device.
print :white_check_mark: :white_check_mark: :white_check_mark: print bytes.

Getting Started

For a full example please check /example folder. Here are only the most important parts of the code to illustrate how to use the library.

Generate bytes to print through flutter_esc_pos_utils.

    import 'package:esc_pos_utils/esc_pos_utils.dart';

    final profile = await CapabilityProfile.load();
    final generator = Generator(PaperSize.mm58, profile);
    List<int> bytes = [];

    bytes += generator.text('Test Print', styles: const PosStyles(align: PosAlign.center));
    bytes += generator.text('Product 1');
    bytes += generator.text('Product 2');

Android

Allow to connect bluetooth (classic and BLE), USB and network devices

Change the minSdkVersion for Android

flutter_pos_printer_platform is compatible only from version 21 of Android SDK so you should change this in android/app/build.gradle:

In build.gradle set

    defaultConfig {
        ...
        minSdkVersion 21
        targetSdkVersion 31
        ...

select type of device PrinterType ( bluetooth, usb, network)

if select bluetooth you can send optional params

  • isBle -> allow to connect with bluetooth that supports this technology
  • autoconnect -> allow to reconnect when state of device is None

iOS

Allow to connect bluetooth (BLE) and network devices

Windows

Allow to connect USB and network devices To network devices is necessary to set ipAddress

How to use it

init a PrinterManager instance
import 'package:flutter_pos_printer_platform/flutter_pos_printer_platform.dart';

    var printerManager = PrinterManager.instance;

scan
    var devices = [];
    _scan(PrinterType type, {bool isBle = false}) {
        // Find printers
        PrinterManager.instance.discovery(type: type, isBle: isBle).listen((device) {
            devices.add(device);
        });
    }
connect
_connectDevice(PrinterDevice selectedPrinter, PrinterType type, {bool reconnect = false, bool isBle = false, String? ipAddress = null}) async {
    switch (type) {
      // only windows and android
      case PrinterType.usb:
        await PrinterManager.instance.connect(
            type: type,
            model: UsbPrinterInput(name: selectedPrinter.name, productId: selectedPrinter.productId, vendorId: selectedPrinter.vendorId));
        break;
      // only iOS and android
      case PrinterType.bluetooth:
        await PrinterManager.instance.connect(
            type: type,
            model: BluetoothPrinterInput(
                name: selectedPrinter.name,
                address: selectedPrinter.address!,
                isBle: isBle,
                autoConnect: reconnect));
        break;
      case PrinterType.network:
        await PrinterManager.instance.connect(type: type, model: TcpPrinterInput(ipAddress: ipAddress ?? selectedPrinter.address!));
        break;
      default:
    }
  }
disconnect
    _disconnectDevice(PrinterType type) async {
        await PrinterManager.instance.disconnect(type: type);
        }
listen bluetooth state
    PrinterManager.instance.stateBluetooth.listen((status) {
      log(' ----------------- status bt $status ------------------ ');
    });
send bytes to print
    _sendBytesToPrint(List<int> bytes, PrinterType type) async { 
      PrinterManager.instance.send(type: type, bytes: bytes);
    }

Troubleshooting

error:'State restoration of CBCentralManager is only allowed for applications that have specified the "bluetooth-central" background mode' info.plist add:

<key>NSBluetoothAlwaysUsageDescription</key>
<string>Allow App use bluetooth?</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>Allow App use bluetooth?</string>
<key>UIBackgroundModes</key>
<array>
    <string>bluetooth-central</string>
    <string>bluetooth-peripheral</string>
</array>

Credits

  • https://github.com/andrey-ushakov/esc_pos_utils
  • https://github.com/bailabs/esc-pos-printer-flutter
  • https://github.com/feedmepos/flutter_printer/tree/master/packages/flutter_pos_printer
  • https://pub.dev/packages/flutter_pos_printer_platform

Support Original Author

If you think that this project has helped you with your developments, you can support this project, any support is much appreciated.

Paypal

カテゴリー

依存関係

依存関係一覧 5 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。