Printing Receipt with Blutetooth Using Flutter

Recently, I bought the bluetooth printer for my sister business. She wants to have receipt everytime clients have done treatment. It's beauty care business. So She needs the customer database and transactions as well. So I made the app first to record all of it. The problem I have is I have never used bluetooth printer before for my projects. Because I don't have one to try.

Fortunately I got one to test the printer. First I need to search the plugin that supports printer bluetooth on Flutter. Because I made the app for iOS and Android. So I need the cross platform framework that is flutter. That I think it's powerful. OK the plugin that I used is esc_pos_bluetooth. It's not easy acuallty to use. Because I have problem using android that I need to fork the repository.

The issue related to android permissions on newest android phone. That the library haven't updated yet, but many people have known the issues. So there are two packages that I fork. It's esc_pos_bluetooth and flutter_bluetooth_basic. I explain what I need these two packages. First with flutter_bluetooth_basic I added two permissions.

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>

I don't know why But android needs these permission to make the printer work. After that in esc_pos_bluetooth you need change the flutter_bluetooth_basic in its package with my flutter_bluetooth_basic package. Because it needs to connect. After that you just need to use esc_pos_bluetooth in you pubspec.yaml

  # The library allows to print receipts using an ESC/POS thermal Bluetooth printer.  
    url: git://  
  esc_pos_utils: ^0.3.6  
Ok after this part, we can try to print it. It's not hard to make it work. First you need to search the bluetooth printer and then click and the printer start printing. That's it. And the code it's simply you can follow the example that the package given. And try to customize on your own.

Maybe the problem you can have is the image when printing. You need to have image that only black and white, never be with colorful color. And one thing about the alignment left and right. I don't know why it's different line when using Row function in this package. 

I hope I can help you to try the bluetooth printer. It's totally possible with flutter on iOS and Android. It works fine. Let me know if you have any questions on comment below. Thanks and enjoy.

Popular posts from this blog

How to restart the app with flutter Android and iOS

How to have ConstraintLayout inside ScrollView and ScrollView inside ConstraintLayout Android

Missing system image Android Studio solution