Code Push

Code Push lets you push Dart code changes to deployed Flutter apps without going through app store review. Users get updates within hours instead of days.

How It Works

Code Push uses Approach B (Engine Swap):

  1. Developers use a standard Flutter SDK from flutter.dev.
  2. The fcp CLI downloads a custom gen_snapshot and engine library that include the code push runtime (C++ patch loader, updater, signature verification).
  3. At build time, fcp codepush release compiles the app with the custom engine and uploads the AOT snapshot as a baseline.
  4. For patches, fcp codepush patch computes a binary diff (BSDIFF50) between the baseline and the new snapshot, signs it, and uploads it.
  5. At runtime, the app uses the flutterplaza_code_push package to check for updates, download patches, and apply them on next restart.

Prerequisites

Quick Start

1. Authenticate

# Opens your browser — sign in and click Authorize
fcp codepush login

2. Download engine artifacts

# Auto-detects your Flutter version
fcp codepush setup

# Or specify version and platform
fcp codepush setup --flutter-version 3.24.0 --platform android-arm64

Artifacts are cached at ~/.flutter_compile/cache/codepush-engine/ and verified with SHA-256 checksums.

3. Register your app

cd my_flutter_app
fcp codepush init

This creates an app on the server and stores the app ID in ~/.flutter_compilerc.

4. Add the runtime package

flutter pub add flutterplaza_code_push

Add the update check to your app:

import 'package:flutterplaza_code_push/flutterplaza_code_push.dart';

Future<void> checkForUpdates() async {
  final update = await CodePush.checkForUpdate();
  if (update.isUpdateAvailable) {
    await CodePush.downloadAndApply(
      onProgress: (p) => print('${(p * 100).toInt()}%'),
    );
    // Patch takes effect on next restart.
  }
}

5. Create a release

# Build and upload baseline
fcp codepush release --build --platform apk

This runs flutter build, swaps the engine library in the build output, and uploads the AOT snapshot to the server.

6. Push a patch

# Make code changes, then:
fcp codepush patch --build --release-id RELEASE_ID --rollout 25

The CLI compiles the patched source, computes a binary diff against the baseline, signs it with your RSA key, packages it as a .vmcode file, and uploads it. Use --rollout for staged rollout (1-100%).

7. Roll back if needed

fcp codepush rollback --patch-id PATCH_ID

CLI Commands

CommandDescription
fcp codepush setup Download code-push engine artifacts for your Flutter version
fcp codepush init Register the current project as an app on the server
fcp codepush login Authenticate via browser (or --api-key for headless)
fcp codepush logout Clear stored credentials
fcp codepush account Show subscription status and account info
fcp codepush release Upload a baseline release (requires paid subscription)
fcp codepush patch Upload a code push patch
fcp codepush rollback Deactivate a patch so devices stop receiving it
fcp codepush status Show releases and patches for an app

Engine Artifacts

The fcp codepush setup command downloads pre-built engine binaries from Google Cloud Storage. Each Flutter version has its own set of artifacts:

PlatformArtifacts
darwin-arm64gen_snapshot, libflutter_engine.dylib
darwin-x64gen_snapshot, libflutter_engine.dylib
linux-x64gen_snapshot, libflutter.so
windows-x64gen_snapshot.exe, flutter_engine.dll
android-arm64gen_snapshot, libflutter.so
ios-arm64gen_snapshot, Flutter.xcframework.tar.gz

Artifacts are cached at ~/.flutter_compile/cache/codepush-engine/flutter-<version>/<platform>/ and verified via SHA-256 checksums.

Engine Swap

When you run fcp codepush release --build, the CLI:

  1. Runs flutter build <platform> --release using the standard SDK.
  2. Replaces the engine library in the build output with the code-push-enabled version:
    • Android: libflutter.so in stripped_native_libs/
    • iOS: Flutter.framework from the xcframework archive
    • macOS: FlutterMacOS in Frameworks/
    • Linux: libflutter_linux_gtk.so in bundle/lib/
    • Windows: flutter_windows.dll in runner/Release/
  3. Optionally re-runs gen_snapshot with --deterministic for stable binary diffs.

Original files are backed up with a .original suffix.

Runtime API

The flutterplaza_code_push package provides the runtime API. Key methods:

MethodDescription
CodePush.checkForUpdate()Check server for available patches
CodePush.downloadAndApply()Download and install the latest patch
CodePush.installPatch(bytes)Install a patch from raw bytes
CodePush.rollback()Remove the active patch
CodePush.currentPatchGet info about the active patch
CodePush.isPatchedCheck if a patch is active
CodePush.releaseVersionGet the base release version
CodePush.patchCountNumber of patches stored on device
CodePush.cleanupOldPatches()Remove inactive patches
CodePush.checkForUpdatePeriodically()Periodic background update checks

Security

IDE Integration

Both the VS Code and IntelliJ / Android Studio extensions include a Code Push panel showing:

Actions like Login, Release, Patch, and Rollback are available directly from the IDE toolbar and context menus.

Pricing

Code push operations (release, patch) require a paid FlutterPlaza subscription. See codepush.flutterplaza.com/pricing for tiers and limits. The fcp codepush account command shows your current tier and subscription status.

Supported Flutter Versions

Run fcp codepush setup --list-versions to see all Flutter versions with available code push engine artifacts.