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.
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'.
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.
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.
You should try flutter-blue.dart for bluetooth receipt printer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With