How to protect the source code of Flutter Web deployed to Firebase Hosting?

Issue

I made a Flutter Website and I deployed to Firebase Hosting, if I inspect the page on Google Chrome, in "Sources" tab it’s possible get the source code of the website.

Is there any way to protect the source code, not having the entire code exposed like this?

enter image description here

Solution

If you look at the source file you will see that it is compiled/minified.

// snippet
var r
var q=d
try{if(a[b]===s){r=a[b]=q
r=a[b]=d()}else r=a[b]}finally{if(r===q)a[b]=null
a[c]=function(){return this[b]}}return r}}function lazy(a,b,c,d){var s=a
a[b]=s

What you are seeing are the sourcemaps which show a developer friendly view of the compiled/minified code. I don’t see any options for turning sourcemaps off.

Something to keep in mind is that you are shipping a client side app. Once code is on other computers there is not much you can do to prevent them from reverse engineering it.

Answered By – abraham

Answer Checked By – Cary Denson (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.