dev

Should Fixing Bluetooth Printing In Flutter Take 3 Days?

Recently I faced the issue of Bluetooth printing in Flutter. But finally solved after 3 days and of course, I take a...

· 2 min read >
qarao.com-58mm-thermal-printer

Recently I faced the issue of Bluetooth printing in Flutter. But finally solved after 3 days and of course, I take a break to get inspiration, and here is the story.

I used 2 printing libraries, esc_pos_utils and esc_pos_bluetooth to solve the printing problem.

So I tried running a sample project from its repository and connected it to the printer successfully.

But there was something wrong while integrating the package into my Android project. There are no error messages, no warning, no useful information for debugging, so in other words, no hints or clues.

At first, I thought the issue came from plugin dependency. After two days of trial and error, and finally on the next day, found the issue came from targetSdkVersion in Android Gradle.

Journey

Okay, it seems a little dramatic 😀 but here are my steps to solve this problem. On my way to finding solutions, I spent a lot of time researching to get the best results that fit my project.

Another story  Six Visual Code Editors That Will Actually Make Your Coding Better

At least until published this story, there are no new compatible versions of these plugins yet.

Day #1

Researching some bluetooth plugins to connect and print. And found bluetooth_printblue_thermal_printeresc_pos_bluetooth, and esc_pos_utils.

The last two was my choice. Testing sample from its repository, the result is passed, it worked!

Then, Integrate into my project, and.. it failed! So I tried to copy the repo into a local project and got the log below

Because mywidget depends on esc_pos_bluetooth 0.2.8 
which depends on esc_pos_utils ^0.3.6, 
esc_pos_utils ^0.3.6 is required. 
So, because mywidget depends on esc_pos_utils ^1.0.0, 
version solving failed.

Day #2

I downgrade library version from version esc_pos_utils: 1.0.0 to esc_pos_utils: 0.3.6. While version esc_pos_bluetooth: 0.2.8 is no change.

Another story  Simple Guidance For You In Connecting Android Emulator To Localhost

I got an amazing thing, actually, no errors but also no printers found LOL! You know if everything seems fine but isn’t really working, it’s hard to debug because there’s no clue.

And … of course, I’ve made sure the printer and Bluetooth are on and connected to my phone.

Day #3

Analyzing a sample project, wondering if it went well in just the sample project? I’m looking for the file what is the cause of this problem.

After several attempts with unsuccessful results as none of the files had any significant differences, I searched Google and saw if anyone else had this problem and resolved it, but I didn’t find the same problem.

So in the end, I manage to open up two Gradle files android/app/build.gradle from the sample and the other from my project. 

Another story  How To Manage My Amazon Ebooks On Kindle And iPhone Better In Less Time

And… after inspecting carefully, found the targetSdkVersion 28 (from the sample) and version 29 from my project, maybe it was the default value from flutter-create command result.

Result

Finally, I downgrade the target to 28, and the problem solved! So I continued to design receipts and this is the result.

Success

Receipt printed successfully via Bluetooth thermal printer. Here are 58mm thermal printer and the receipt.

qarao.com-receipt-bluetooh-printing-in-flutter
Here is the result after 3 days LOL!

Maybe next time I’ll tell you this receipt design process 🙂 but I’m wondering how to print vertical text for labels. There is an optional parameter in esc_pos_utils that change 90 degrees for the text but no effect.

Thank you all

And the important thing is.. thanks all for those plugins creator for Bluetooth printing in Flutter. All of you so wonderful.

11 Replies to “Should Fixing Bluetooth Printing In Flutter Take 3 Days?”

  1. hi, I am also facing the same issue while searching the Bluetooth printer in my flutter app. The solution which you provided I tired, but not worked for me. Can you please chare the project folder if you can.

  2. Excellent post. I was checking constantly this blog and I’m impressed!
    Very useful info specifically the final part 🙂 I take care of such info a lot.
    I used to be looking for this particular information for a long time.
    Thank you and best of luck.

  3. You could definitely see your expertise within the
    work you write. The world hopes for even more passionate writers like you who
    are not afraid to mention how they believe. All the time follow your heart.

    starmoon

  4. Hey! This is kind of off topic but I need some guidance from an established blog.
    Is it very hard to set up your own blog? I’m not very techincal but I
    can figure things out pretty fast. I’m thinking about setting up my own but I’m not sure where to start.
    Do you have any tips or suggestions? Thank you

  5. Howdy would you mind letting me know which hosting company
    you’re utilizing? I’ve loaded your blog in 3 different
    browsers and I must say this blog loads a lot
    faster then most. Can you recommend a good hosting provider at a honest price?

    Kudos, I appreciate it!

  6. Attractive part of content. I just stumbled upon your web site and in accession capital to assert that
    I get in fact loved account your weblog posts. Anyway I’ll
    be subscribing for your augment or even I success you get right of entry to persistently
    rapidly.

  7. Thanks for one’s marvelous posting! I seriously enjoyed reading it, you might be a great author.I will be sure to bookmark your blog and will come back from
    now on. I want to encourage that you continue your great posts, have
    a nice evening!

  8. Heya i’m for the first time here. I came across this board and I find
    It really useful & it helped me out much. I hope to give something
    back and aid others like you helped me.

Leave a Reply

Your email address will not be published. Required fields are marked *

Right Menu Icon