flutter_bluetooth_printer

Last updated:

0 purchases

flutter_bluetooth_printer Image
flutter_bluetooth_printer Images
Add to Cart

Description:

flutter bluetooth printer

flutter_bluetooth_printer #
A flutter plugin for print a receipt over bluetooth thermal printer.
Getting Started #
Depend on it:
dependencies:
flutter_bluetooth_printer: any
copied to clipboard
Make your receipt
ReceiptController? controller;

Widget build(BuildContext context){
return Receipt(
/// You can build your receipt widget that will be printed to the device
/// Note that, this feature is in experimental, you should make sure your widgets will be fit on every device.
builder: (context) => Column(
children: [
Text('Hello World'),
]
),
onInitialized: (controller) {
this.controller = controller;
},
);
}
copied to clipboard
Select a device and print:
Future<void> print() async {
final device = await FlutterBluetoothPrinter.selectDevice(context);
if (device != null){
/// do print
controller?.print(address: device.address);
}
}
copied to clipboard
Custom Device Selector #
You can make your own device selector using FlutterBluetoothPrinter.discovery stream to discover available devices.
Widget build(BuilderContext context){
return StreamBuilder<List<BluetoothDevice>>(
stream: FlutterBluetoothPrinter.discovery,
builder: (context, snapshot){

final list = snapshot.data ?? <BluetoothDevice>[];
return ListView.builder(
itemCount: list.length,
itemBuilder: (context, index){
final device = list.elementAt(index);
return ListTile(
title: Text(device.name ?? 'No Name'),
subtitle: Text(device.address),
onTap: (){
// do anything
FlutterBluetoothPrinter.printImage(
address: device.address,
image: // some image
);
}
);
}
);
}
);
}

copied to clipboard
Print PDF or Image #
You can print a PDF or an Image that contains your receipt design.
For a PDF file, you can use any package that convert your PDF to an image.
Then you can print it using command below:
FlutterBluetoothPrinter.printImage(...);
copied to clipboard
Note that, we are currently using package image.
Print Custom ESC/POS Command #
You still able to send an ESC/POS Command using command below:
FlutterBluetoothPrinter.printBytes(...);
copied to clipboard
Do you like my work? #

Discord #
Click here to join to my discord channels

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.