Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter - How to print a receipt to bluetooth printer?

Tags:

flutter

i m new to Flutter, and basicly i m still learning. I need to create a "print" receipt through a bluetooth printer module. The case is about shop app, i select some items, and it sums the total price. In the end i submitted, and it prints the receipt through bluetooth printer. I ve tried to search some plugin like pauldemarco's flutter_blue, but i still didnt get it how to do the print thing. I m using flutter, and i pull the data from MySQL.

My question is, "How to print a receipt display using bluetooth printer"?

Can anyone provide me some simple explanation, and if i can kindly ask a simple example code for it?

Thanks in advance.

like image 559
GNM Avatar asked May 31 '18 03:05

GNM


People also ask

How do I connect my Bluetooth receipt to my printer?

In your mobile device, go to Settings > Bluetooth, and turn the 'Bluetooth' on. A Bluetooth device search will begin, and you will see your printer on the list. Push the 'Pair' button on your printer. On your mobile device, choose your printer's model from the list of 'Devices'.

How do I print a receipt in Flutter?

first, you have to create a print widget, which I named a printing screen. now you have to create a receipt model and execute that model when pressing a button. In simple terms, you have to design a receipt, how it displays data. If you are using State management in a flutter.


2 Answers

Bluetooth API is a platform-specific API, so you should use Platform Channel in Flutter to deal with those APIs in the separate platform (Android and iOS). In a word, Platform Channel supports you communicate between Dart module and native module (android and ios)

From Dart module, user triggers an action of printing something, Dart module will send a message to the native module to request printing action, native module calls some specific APIs of OS to do it and when it's done, the native module sends back the result to Dart module to show the result to user.

like image 126
hunghd Avatar answered Oct 20 '22 00:10

hunghd


You should try flutter-blue.dart for bluetooth receipt printer

like image 37
Tin Tin Nwe Avatar answered Oct 19 '22 22:10

Tin Tin Nwe