/rongta_printer

Primary LanguageObjective-CApache License 2.0Apache-2.0

rongta_printer

Flutter Version License Platform

A Flutter plugin for printing using Rongta thermal printers. 🖨️

Features

  • Print anything 🤯: Print any widget shape, bypassing the limitations of the Rongta native SDK.
  • Be aware of the printer status 💡: Receive updates about printer connection and document transmission.

Installation

Add the following dependency to your pubspec.yaml file:

plugin_name: ^1.0.0

Setup

The code works for Android out of the box, and has 1 step to setup iOS.

🔧 iOS Setup

To run the plugin on iOS, you need to add the bluetooth framework, to do so please follow these steps:

  1. Tap on runner from the left side navigator.
  2. Select the target from the targets list.
  3. Tap on build phases.
  4. Add a new "Link Binary With Libraries" by hitting the + button.
  5. Type "Bluetooth" in the search bar and choose the CoreBluetooth.framework.

alt text

Usage

Import the package into your Dart file:

import 'package:rongta_printer/rongta_printer.dart';

Example

Initialize the connection with the printer:

...
final _rongtaPrinterPlugin = RongtaPrinter();

void onConnectionStatusChanged(PrinterConnectionStatus status) {...}
void onOperationStatusChanged(PrinterOperationStatus status) {...}
...
await _rongtaPrinterPlugin.init(
  macAddress: 'DC:0D:30:95:39:A2',
  onPrinterConnectionChange: onConnectionStatusChanged,
  onDocPrinted: onOperationStatusChanged,
);
...

Print your document:

...
_rongtaPrinterPlugin.print(
  doc: Column(
    children: const [
      FlutterLogo(),
      Text('Rongta printing example'),
    ],
  ),
);
...

Known Issues ❗️

  • Using Image.memory will not display anything, as the code loads images instantly, while loading from memory takes time.

License

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

Contributing

Contributions are welcome! Please feel free to submit a pull request.

Acknowledgments

The code is built on top of the Rongta SDKs for Android and iOS, which can be found here. 🙌