easy_thermal_print 0.1.3+2
easy_thermal_print: ^0.1.3+2 copied to clipboard
a package for accessing thermal printers via flutter
Easy Thermal Print #
A Flutter package for easy thermal printing. It provides a simple API that lets you print text, or custom widgets to a thermal printer. The package currently supports Bluetooth Low Energy (BLE) printers and is thus compatible with all platforms that support BLE.
Features #
- Print text and custom widgets to thermal printers.
- Support for Bluetooth Low Energy (BLE) printers.
- customizable print settings:
- Label Size / continuous paper
- optional half-tone printing
- Text styling
- dry run mode for testing without a printer
- view print output via
PrintedViewer
widget
Supported Devices #
- out-of-the-box support for:
- Phomemo printers
- support for other BLE thermal via config (feel free to reach out, so we can add it to the included list)
Example #
Usage #
-
import the package:
flutter pub add easy_thermal_print
-
initialize the Bluetooth service and discover devices
/// create a new instance of the BluetoothService. /// provide a list of printers to scan for. /// ⚠️ make sure the user grants the permissions before scanning final bluetoothService = BluetoothPrintersService( printers: [...phomemoPrinters], );
bluetoothService.discover(); // devices will appear in: bluetoothService.connectedPrinters
-
start printing 🎉
printer.printWidget( // or printText containerKey, PrintConfig(halfTones: true,labelSize: Size(60, 12)), );
- make sure to wrap the stuff you want to print in a
Printable
widget
- make sure to wrap the stuff you want to print in a
Required Permissions #
Android
Add the following permissions to your AndroidManifest.xml
:
...
<uses-feature android:name="android.hardware.bluetooth_le" android:required="false" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
</manifest>
iOS / macOS
Add the following keys to your Release/Debug.entitlements
:
...
<key>com.apple.security.device.bluetooth</key>
<true/>
</dict>
</plist>
Project Acknowledgements: #
- phomemo-tools for details regarding the printing protocol
- phomemo for the setup for printing widgets to an image
Yours, Robin