Log date · Mon
Does Flutter obfuscation protect code and secrets?
Published on · Updated
Flutter obfuscation renames Dart symbols, not secrets. We test split debug information and explain how to retain release symbols.
Can Flutter obfuscation protect code and secrets?
Flutter obfuscation renames Dart symbols to make code harder to read; it does not encrypt resources or turn a secret embedded in the client into a secret. [1] We compiled the same small program with Dart 3.11.4: both the regular executable and the one with separate debugging information retained a complete fake key and a function name. The regular executable was 5,569,776 bytes; the split executable was 5,356,368 bytes, with a separate 303,069-byte debug file.
The comparison shows that debug information and visible strings are different things. The standalone Dart compiler rejected --obfuscate; Flutter’s release obfuscation command and the Dart experiment below are different workflows.
| Question | Finding |
|---|---|
| Is the fake key still present? | An exact match is present in both Dart executables. |
| What changes in the split stack trace? | The sample trace uses addresses; debug information is saved separately. |
| Does Flutter obfuscation encrypt assets? | No, according to the Flutter documentation. |
| Can this standalone Dart compiler accept --obfuscate? | The installed version rejects it. |
Sample and setup
We wrote a fictional quote program that prints an obviously fake key and calculates a discount; passing fail deliberately throws an error. A never-inline pragma keeps the call visible for the stack trace. We ran the Flutter SDK’s Dart 3.11.4 on macOS 27.2 arm64, comparing standalone Dart executables, not Flutter apps or obfuscated Flutter artifacts.
const demoMarker = 'DEMO-KEY-not-a-real-credential-0000';
@pragma('vm:never-inline')
int calculateLoyaltyDiscount(int units) {
if (units < 0) throw ArgumentError('invalid quote units');
return units >= 100 ? 12 : 5;
}
void main(List<String> args) {
print('marker: $demoMarker');
print('discount: ${calculateLoyaltyDiscount(args.contains("fail") ? -1 : 100)}');
}Dart describes exe as a self-contained executable containing compiled machine code and a Dart runtime. [2] We compiled the same source twice, adding --save-debugging-info only for the second build. That option handles debugging information; it is not evidence that Flutter symbol obfuscation was applied.
Measured: strings and stack traces
Both programs printed the same placeholder and a 12% discount in the normal run. We then checked the files for exact byte sequences and triggered an exception. The four lines below come from the transcript; the search covers only these two known strings.
regular | DEMO-KEY-not-a-real-credential-0000 | present
regular | calculateLoyaltyDiscount | present
split | DEMO-KEY-not-a-real-credential-0000 | present
split | calculateLoyaltyDiscount | presentThe regular exception trace names calculateLoyaltyDiscount and its source location; the split trace shows addresses and snapshot instruction symbols. Even though the trace format changed, the exact function-name match in the file remained present. Those observations are compatible: the information used to format a trace and the presence of a byte sequence in a file are separate questions.
The split executable was 213,408 bytes smaller than the regular one, but its separate debug file was larger than that saving. Sizes depend on the toolchain, platform and program; these numbers describe this sample, not an obfuscation rate or a security score. A failed exact match would not prove that a value cannot be obtained from another representation or from runtime behavior.
What Flutter obfuscation does
Flutter describes obfuscation as replacing names of symbols such as functions and classes in compiled Dart code. It applies to release builds; it does not encrypt assets or guarantee protection against reverse engineering. [1] Debug, profile and release modes serve different purposes, so assess the final release configuration rather than substituting a debug build. [3]
Review assets, native plugins and server-side permissions separately. Obfuscation can also break logic that depends on string representations of class, function or library names; the documentation notes that enum names are currently not obfuscated. [1] For example, replace comparisons between runtimeType.toString() and a fixed class name with checks that do not depend on the name, then exercise those paths in the obfuscated build.
Treat web separately: Flutter says the obfuscation workflow described here is not supported for web, whose release build is minified. [1] Do not assume the native symbol-file and diagnostic workflow applies unchanged to web minification.
Keep symbols with the exact release
Flutter’s build command pairs obfuscation with --split-debug-info. The documentation says to retain the generated symbols for future stack traces and select the file matching the crash target and architecture. [1] A practical release record ties the version, build identifier, target architecture, artifact digest and symbol-file location together.
Store symbols and any optional name map in a controlled internal location with the release, rather than relying on a developer’s temporary directory. Before shipping, produce a test trace from that build and confirm that the team can locate the matching file and interpret it. Windows x64 uses a PDB; Flutter says flutter symbolize does not support that format and directs developers to a Windows debugger. [1]
| Goal | Recommendation |
|---|---|
| Raise the cost of reading Dart names | Enable release obfuscation on a supported target and run functional tests. |
| Diagnose production crashes | Retain symbols by build and architecture and rehearse symbolization. |
| Protect a shared server secret | Move its use to a controlled server and support rotation. |
| Review assets or native plugins | Inventory and review them separately; Dart symbol renaming is not asset protection. |
Run this on your own app
First check that the Flutter version and target used by your project expose these options. The Android APK example below uses a symbols directory that should be controlled in CI and unique to the build; replace the paths with your own. These commands are a documented operational example, not executed on a Flutter app in this experiment.
flutter build apk -h
flutter build apk --release --obfuscate --split-debug-info=build/private-symbolsInstall the final artifact and test important flows, especially name-dependent branches, plugin calls and error handling. Use the internal release record to find the symbols for the matching architecture; save the actual trace to a file before symbolizing it. Traces can contain user data, so keep them out of public locations.
flutter symbolize -i path/to/stacktrace.txt -d path/to/app.android-arm64.symbolsFinally inventory configuration, assets and credentials delivered with the package. Move privileged shared secrets to a controlled server; if an older release already contains a live credential, restrict and rotate it and verify the old value stops working. Obfuscation can be one step in a release process, but it cannot replace permission design, asset review and a crash-diagnosis rehearsal.
When comparing releases, first fix dependencies, build arguments and target architecture. Record functional results, package size and crash diagnosis for the unobfuscated and obfuscated builds separately. Keep each build’s own symbols: even if the source is unchanged, a rebuild should use the files associated with the actual artifact. If a test fails, identify name-dependent code or a third-party component before choosing a repair. Record the build identifier and regression results so the next team can reproduce the issue, rather than judging release quality from the presence of an obfuscation flag alone.
Your checklist
- Check release obfuscation options for the target and run functional tests.
- Review assets, native plugins and client credentials.
- Remove and rotate any shipped privileged shared secrets.
- Retain symbol files by build and architecture.
- Rehearse diagnosis with a test trace from the release build.
Primary sources
- Flutter: Obfuscate Dart code · Checked 2026-11-11
- Dart: dart compile · Checked 2026-11-11
- Flutter build modes · Checked 2026-11-11