Flutter's wiki mentions obfuscation is an opt-in in release mode.
And yet, the flutter build command has no relevant option - see:
flutter help -v build apk
Am I missing something here?
Did they make obfuscation the default?
Is obfuscation even relevant for flutter?
Any pointers on this would be very appreciated.
At the moment obfuscation is not directly exposed via the flutter CLI.
You can try to explicitly pass arguements to the
gen_snapshot
like this:Note: that obfuscation support is not very well tested and might not work at the moment.
Obfuscation is needed - a flutter app knows its function names, which can be shown using Dart's StackTrace class. There's under-tested support for obfuscation. To enable it:
For Android:
Add to the file
[ProjectRoot]/android/gradle.properties
:For iOS:
First, edit
[FlutterRoot]/packages/flutter_tools/bin/xcode_backend.sh
:Locate the
build aot
call, and add a flag to it,defined as:
To apply your changes, in [FlutterRoot], run
(Running "flutter" after the commit rebuilds flutter tools.)
Next, in your project, add following to
[ProjectRoot]/ios/Flutter/Release.xcconfig
file:PS: Haven't tried the --save-obfuscation-map flag mentioned at https://github.com/dart-lang/sdk/issues/30524
Again, obfuscation isn't very well tested, as mentioned by @mraleph.