A Flutter plugin for printing using Rongta thermal printers. 🖨️
- 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.
Add the following dependency to your pubspec.yaml
file:
plugin_name: ^1.0.0
The code works for Android out of the box, and has 1 step to setup iOS.
To run the plugin on iOS, you need to add the bluetooth framework, to do so please follow these steps:
- Tap on runner from the left side navigator.
- Select the target from the targets list.
- Tap on build phases.
- Add a new "Link Binary With Libraries" by hitting the + button.
- Type "Bluetooth" in the search bar and choose the CoreBluetooth.framework.
Import the package into your Dart file:
import 'package:rongta_printer/rongta_printer.dart';
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'),
],
),
);
...
- Using
Image.memory
will not display anything, as the code loads images instantly, while loading from memory takes time.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a pull request.
The code is built on top of the Rongta SDKs for Android and iOS, which can be found here. 🙌