MCPcopy Create free account
hub / github.com/caverav/flutterdec

github.com/caverav/flutterdec @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
943 symbols 2,105 edges 73 files ⚖ MIT 0 documented · 0% ● updated 4d agov0.1.0-alpha.4 · 2026-08-08★ 1434 open issues

Browse by type

⨍ Functions 821◇ Types & classes 122
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

flutterdec banner

flutterdec

CI Release License: MIT

A static decompiler for Flutter Android apps. Point it at an APK or a libapp.so and it recovers readable Dart-like pseudocode, ARM64 disassembly, an intermediate representation, build-to-build diffs, and structured reports. Everything runs offline on your machine: the target is never executed.

  • Input: a Flutter app for Android built for ARM64, as an APK or a bare libapp.so
  • Output: a project-shaped tree of .dart files under lib/, packages/, and sdk/, with one file per library by default (--layout project keeps one file per function), plus index.json, report.json, and quality.json, with optional asm, IR, and symbol scripts
  • Use it for: reversing an app, reviewing it for hardcoded secrets or logic flaws, or diffing two releases
  • Status: alpha research tool; see Project status

If you remember only three commands:

  1. flutterdec info tells you what the target is.
  2. flutterdec adapter install gives the decompiler real Dart names for that target.
  3. flutterdec decompile produces the pseudocode and reports.

Contents

What you get

Artifact What it is
lib/**/*.dart App or root-package code, one file per library by default. Start here.
packages/**/lib/**/*.dart Dependency-package code, rooted at each package name.
index.json Function-to-source mapping with ids, libraries, classes, line spans for composed functions, entry addresses, and provenance.
report.json and quality.json What was analyzed, what was recovered, and how complete it was.
artifacts/asm/**/*.s and artifacts/ir/**/*.json Lower-level views to verify the pseudocode (--emit-asm --emit-ir).
ghidra_apply_symbols.py / ida_apply_symbols.py Recovered names for Ghidra or IDA (--emit-ghidra-script, --emit-ida-script).
diff_report.json Function and package churn between two builds (flutterdec diff).

What it is not

  • Not the original source. It reconstructs readable approximations. Names, types, and comments are best effort, so verify anything important against the asm and IR.
  • Not dynamic analysis. The app is never executed. No emulator, device, or instrumentation is involved.
  • Not multi-platform. Supported targets are Android Flutter AOT builds for ARM64. iOS, x86/x86_64, and JIT/debug builds are not supported at this maturity.
  • Not finished. This is alpha software. Output quality varies by app and Dart/Flutter version, and the command set can change between prereleases.

Requirements

Target A Flutter release build for Android ARM64 (arm64-v8a), as an APK or an extracted libapp.so. Debug/JIT builds cannot be decompiled.
Input Any file on disk. A split APK works as long as it includes the arm64-v8a split, or you can use a universal APK.
Host Linux x86_64 or macOS Apple Silicon for the prebuilt binaries. Other systems can build from source with Nix.
Runtime Nothing beyond the CLI binary. Analysis is fully static and offline.
Optional Nix for the zero-install path; a Rust toolchain (provided by nix develop) to build from source.

Installation

Flutter release apps ship their compiled Dart code as lib/arm64-v8a/libapp.so inside the APK. flutterdec accepts either the APK or the extracted libapp.so.

Option 1: Nix, no installation (recommended)

If you have Nix installed, one command runs the latest main without touching your system:

nix run github:caverav/flutterdec -- --help

Every example in this README works through that entry point, for example:

nix run github:caverav/flutterdec -- info ./app.apk --json
nix run github:caverav/flutterdec -- decompile ./app.apk -o ./out

To install it permanently instead:

nix profile install github:caverav/flutterdec
flutterdec --help

Update later with nix profile upgrade flutterdec.

Option 2: Prebuilt release binary

Download the archive for your platform from the Releases page: Linux x86_64 or macOS Apple Silicon. The current prerelease is v0.1.0-alpha.4.

[!IMPORTANT] The standalone v0.1.0-alpha.4 binary can inspect a target (flutterdec info), but it cannot install adapters or decompile without the packaged producer and registry from a source checkout. For decompilation today, use Nix (Option 1) or a source checkout (Option 3).

The archive contains a single flutterdec binary:

# Linux x86_64
curl -fLO https://github.com/caverav/flutterdec/releases/download/v0.1.0-alpha.4/flutterdec-v0.1.0-alpha.4-Linux-X64.tar.gz
tar -xzf flutterdec-v0.1.0-alpha.4-Linux-X64.tar.gz

# macOS Apple Silicon
curl -fLO https://github.com/caverav/flutterdec/releases/download/v0.1.0-alpha.4/flutterdec-v0.1.0-alpha.4-macOS-ARM64.tar.gz
tar -xzf flutterdec-v0.1.0-alpha.4-macOS-ARM64.tar.gz

# install the binary, then verify
sudo mkdir -p /usr/local/bin
sudo install -m 0755 flutterdec /usr/local/bin/flutterdec
flutterdec --version

Releases built from current main will ship a different layout: a prefix with bin/flutterdec plus the compatibility registry, the runtime profiles, and the packaged producer under share/flutterdec. On those releases the CLI resolves its data relative to its own executable, so keep bin and share together and copy both (sudo cp -R bin share /usr/local/).

Option 3: Build from a checkout

This is the route for contributors, or for running unreleased code:

git clone https://github.com/caverav/flutterdec.git
cd flutterdec
nix develop -c cargo build -p flutterdec-cli --release
./target/release/flutterdec --help

You can also run directly from the checkout without building, with nix run . -- --help. The resulting CLI finds the adapters/ registry and data/ profiles in the repository, so adapters work out of the box.

Quick start: your first decompile

This walkthrough takes a few minutes on a normal machine. It uses app.apk and ./out as example paths; replace them with your own.

Step 1: Inspect the target

flutterdec info ./app.apk --json

info reads the snapshot identity out of the header, with no adapter installed and no disassembly. It tells you what you need next:

  • snapshot_hash: the identity of the compiled Dart snapshot, and the value adapter install takes
  • arch and snapshot_features: the target architecture and the engine build characteristics
  • registry_record_present and the compatibility block: whether a known adapter covers this app, and if not, why (identity_rejection)

For APK inputs, info also reports manifest-derived startup signals (android_startup_present, android_startup_confidence, android_startup_entrypoint_count, android_startup_flutter_activity_count). When adapter metadata is available it reports app package counts and compatibility warnings too.

The dart_aliases, dart_version, and dart_tag_style fields describe the matched registry record. Aliases are provenance labels and never select a parser or profile; dart_version is a display value (unverified when the record carries aliases, unavailable when it carries none); all three are null when no record matches or its adapter is not installed.

No adapter is needed for this step. --json prints the full report; omit it for a plain-text summary.

Step 2: Install the adapter (recommended)

flutterdec adapter install --dart-hash <snapshot_hash from step 1>
flutterdec adapter list

An adapter is a small, hash-specific parser that knows how one Dart snapshot version lays out libraries, classes, function names, and the object pool. Installing the adapter for your target is what turns anonymous ARM64 into named, readable code.

  • adapter install refuses a hash the compatibility registry has no record for, a record that does not serve this host, and any artifact whose bytes do not match the digest and size the record declares. Installs are atomic, safe to run concurrently, and report already-installed when the store is already correct.
  • adapter list reports a verified state per record: verified, missing, corrupt, incompatible, or unavailable. It exits 2 when the store holds an install it cannot back.

If no record covers your hash, skip this step. decompile still runs using core recovery and says so in report.json; see Fallbacks and core recovery.

Step 3: Decompile

flutterdec decompile ./app.apk -o ./out

By default this focuses on app-owned code (--function-scope app-unknown) and excludes Flutter and Dart framework internals.

Step 4: Read the results

Start with these files, in this order:

  1. out/lib/**/*.dart - the recovered logic, one file per library
  2. out/index.json - the map from each function to its source file, line span, and provenance
  3. out/report.json - what was analyzed and what was recovered
  4. out/quality.json - how complete the recovery was

About the exit code 1 you will probably see

[!IMPORTANT] A non-zero exit is expected on a real app, and your artifacts are still written. The strict quality gate is on by default (--max-placeholder-ifs 0), and every real Flutter app contains placeholder if statements the decompiler could not fully resolve. The command prints reasons: placeholder if-count exceeded threshold, exits 1, and still writes every artifact listed above. Nothing is missing; the gate is reporting a quality measurement, not a failure to decompile.

Measured on LocalSend 1.17 at the default scope: 501 placeholder ifs across 5,800 pseudocode files, exit 1.

Read your own number rather than guessing one. It is placeholder_ifs in out/quality.json, and it grows with scope. Setting the threshold from that measurement is the point: a huge round number silences the gate permanently, whereas a real one still fails when the count rises, which is the only thing the gate is useful for. Keep the strict default in CI.

flutterdec decompile ./app.apk -o ./out            # exits 1, writes everything
python3 -c "import json;print(json.load(open('out/quality.json'))['placeholder_ifs'])"
flutterdec decompile ./app.apk -o ./out --max-placeholder-ifs <that number>

The other gates are --max-unresolved-cf, --max-indirect-call-ratio, and --min-disassembly-ratio. See the CLI reference for their defaults and for --split-records.

How it works

A Flutter release compiles Dart ahead-of-time (AOT) to ARM64 machine code and packs it, with a snapshot header and an object pool, into libapp.so. Symbols and source are gone; names survive only as metadata. flutterdec walks the pipeline below and records what it recovered at each stage.

APK / libapp.so
      |
      v
 [1] Loader ------> [2] Adapter ------> [3] ARM64 disassembly
                                              |
                                              v
                                  [4] IR + control-flow graph
                                              |
                                              v
                                  [5] Pseudo-Dart decompiler
                                              |
                                              v
                                  [6] quality.json + report.json
  1. Loader - opens the APK or ELF and locates the snapshot blob.
  2. Adapter - parses the version-specific snapshot format to recover libraries, classes, function names, and object-pool layout. Adapters are hash-verified and run as a bounded, one-shot job; report.json records which execution controls were actually established.
  3. Disassembly - decodes ARM64 and annotates Dart ABI details such as register and pool loads.
  4. IR / CFG - lifts instructions into an intermediate representation and rebuilds basic blocks.
  5. Decompiler - emits structured pseudo-Dart: branches, loops, returns, and named callsites.
  6. Quality and reporting - counts unresolved constructs and writes the reports and artifacts.

Auxiliary commands extend this core: map-symbols derives engine symbol names from a stripped/unstripped pair, engine-fingerprint identifies an engine build from an ELF, symbol ingestion feeds those names into decompile, and diff compares two builds at recovered-function level.

Adapters and backends

The backend that parses the snapshot decides how much is actually recovered:

Backend Function names Classes ObjectPool
internal / core recovery none at all; code ranges are unnamed none unavailable
serwalker recovered snapshot name

Core symbols most depended-on inside this repo

browse all functions →

Shape

Function 687
Method 134
Class 106
Enum 16

Languages

Rust97%
Python3%
Kotlin1%

Modules by API surface

crates/flutterdec-core/src/pipeline/apk_startup.rs87 symbols
crates/flutterdec-disasm-arm64/src/lib.rs71 symbols
crates/flutterdec-core/src/pipeline/runners.rs57 symbols
crates/flutterdec-decompiler/src/tests/emit_and_helpers/readability_and_naming.rs53 symbols
crates/flutterdec-core/src/pipeline/runners/tests.rs52 symbols
crates/flutterdec-decompiler/src/tests/cfg_and_stack/call_and_loops.rs46 symbols
crates/flutterdec-cli/src/main.rs44 symbols
crates/flutterdec-core/src/pipeline/runners/manifest.rs43 symbols
crates/flutterdec-core/src/pipeline/runners/symbols.rs30 symbols
crates/flutterdec-decompiler/src/passes/structural_helpers/naming_support.rs27 symbols
adapters/python/adapter_template.py27 symbols
crates/flutterdec-decompiler/src/lib.rs24 symbols

For agents

$ claude mcp add flutterdec \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page