
Flutter Pdfview crashes on release
Hey there! do you code flutter? if you do, I’m gonna share something no one wants to talk about on a good day.
Have you ever used the flutter_pdfview plugin? or have you ever thought of using it or just maybe you haven't even heard about it? Well just to give you a heads up, I recently build a project that required me to load in pdf files, and my first go to was the flutter_pdfview. I did all that was needed to be done and moved on to other aspects of my app. Fast-forward one month later, I felt it was time to do a release and see how my app worked on a couple of phones aside mine. So I ran:
flutter build apk — release
and the app was built. I installed and everything works perfectly right but not so fast. I went on to view some pdfs on my app and walla! app crashed.
Long story short it took me four days of chess-playing, Netflixing, and anger management to figure out what went wrong by taking a more subtle approach, “The Art of Detailing” which is one of my core principles of programming even though I suck at it sometimes. So here's the deal, I googled the problem and discovered I needed a Flutter and Android obfuscation in my project, which led me to proguard.
What is Proguard?
Proguard is a free Java class file shrinker, optimizer, obfuscator, and verifier. It detects and removes unused classes, fields, methods, and attributes. It optimizes bytecode and removes unused instructions. It renames the remaining classes, fields, and methods using short meaningless names.
After adding proguard, with help from this medium article https://medium.com/@swav.kulinski/flutter-and-android-obfuscation-8768ac544421
You would have guessed my problem has been solved well not at all.
The Art of Details
My problem only halfway solved and all I need was one more ingredient of my 3 reasons why programmers hate programming articles (link). To cut my story short, I only needed to add one line to my proguard file which looked like this

Then I added
***-keep class com.shockwave.**

and it worked, I felt relieved. I could now view my pdf files. so here my point on paying a little more attention to details, all along this instruction was lying at the flutter_pdfview package instruction web page https://pub.dev/packages/flutter_pdfview

but I never saw it, simply cause I wasn't looking well enough.
As much as we want to build and build real fast. Detailing is one of the keys to every aspect of our craft as programmers and co-creators of technology.
Thanks for reading, I hope I wasn't super boring.
Please follow me here on medium, on twitter, and Instagram.
Twitter: https://twitter.com/samuelezedi
Instagram: https://instagram.com/samuelezedi