Integrate the SDKNew

Flutter

Use FireOTA in a Flutter app with the fireota package: Dart code patches on Android, asset and config updates on Android and iOS.

7 sections Edit this page on GitHub

What you get

AndroidiOS
Dart code patchesYes (opt-in)No
Asset and remote-config updatesYesYes
Signing, staged rollouts, automatic rollbackYesYes

A code patch is your app's compiled Dart code, built with the same Flutter version as the store build it targets. On the next cold start the SDK hands it to the Flutter engine. If the patch doesn't load or crashes before its first frame, the app goes back to its previous code and reports it on the dashboard.

Install

bash
flutter pub add fireota
npm install -g @fireota/cli
fireota init --app YOUR_APP_ID --server-url https://fireota.example.com
  • Writes lib/fireota_config.dart with your app ID, server URL and channel.
  • Starts FireOTA in main() before runApp.
  • Makes MainActivity extend FireOTAFlutterActivity, which starts the engine with the installed patch.

Or set it up by hand:

dart
import 'package:fireota/fireota.dart';
import 'package:flutter/material.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await FireOTA.init(const FireOTAConfig(
    appId: 'YOUR_APP_ID',
    serverUrl: 'https://fireota.example.com',
    allowCodePush: true, // Android code patches; read "Store policy" first
    autoDownload: false, // ask before downloading, with FireOTAUpdatePrompt
    codeSigningCertificate: '''-----BEGIN PUBLIC KEY-----
...
-----END PUBLIC KEY-----''',
  ));
  runApp(const MyApp());
}

// The update dialogs (Material 3, your app's theme): add once
MaterialApp(
  builder: (context, child) => FireOTAUpdatePrompt(child: child!),
  home: const HomePage(),
);
kotlin
// android/app/src/main/kotlin/.../MainActivity.kt
import dev.fireota.flutter.FireOTAFlutterActivity

class MainActivity : FireOTAFlutterActivity()

FireOTAUpdatePrompt shows the same flow as the React Native SDK — “Update available” → Update → download progress → “Update ready” → Restart now — as Material 3 dialogs that use your app's Theme, light and dark. Change the text with FireOTAPromptLabels.

Note: The runtime version is your pubspec.yaml version with its build number, for example 1.4.0+12. A patch only reaches devices running that exact store build, so bump the version for every store release.

Ship a Dart code patch (Android)

  1. 1
    Create a signing key with fireota signing generate. Add the public key under Code signing and to codeSigningCertificate. Code patches are always signed.
  2. 2
    Build the store build and record its fingerprint. Commit the file under .fireota/flutter/: patches built later, for example in CI, are checked against it.
    bash
    # Once per store release: build it and record its fingerprint
    fireota flutter release android
    git add .fireota/flutter && git commit -m "Record store build 1.4.0+12"
  3. 3
    Upload build/app/outputs/bundle/release/app-release.aab to Google Play as usual.
  4. 4
    Change Dart code and publish a patch. Start with a small rollout and raise it from the dashboard.
    bash
    export FIREOTA_URL=https://fireota.example.com
    export FIREOTA_API_KEY=fota_sk_...
    fireota flutter patch android --app YOUR_APP_ID \
      --private-key fireota-private.pem --message "Fix checkout total" --rollout 10

fireota flutter patch refuses to build when your Flutter version or engine differs from the store build, or when plugins with native code were added, removed or upgraded. Those changes need a store release.

Asset and config updates (Android and iOS)

bash
fireota flutter assets --platform all --app YOUR_APP_ID \
  --assets ./ota-assets --config ./config.json --message "Holiday theme"
dart
FireOTAImage('assets/banner.png')        // updated file, or the bundled asset
final theme = FireOTA.config['theme'];   // remote config from config.json

Asset updates apply on the next start on Android. On iOS, FireOTA.restart() switches them in place.

Store policy

Important: Google Play forbids downloading executable code from outside Google Play, except code that runs in a virtual machine or interpreter. A code patch is compiled Dart code that runs in the Dart VM. Whether that falls under the exception is your call, so code push is off by default(allowCodePush: false).
  • Turn it on for enterprise, MDM or sideloaded apps, or after your own policy review.
  • For Play apps that can't take the risk, use asset and config updates only.
  • Never change what the app is for through a patch; ship features through the store.
  • On iOS the SDK only installs assets and config, which App Store guideline 3.3.2 allows.

Limits

  • iOS code push needs a modified Flutter engine and a Dart interpreter, which the package doesn't include.
  • Native code (Kotlin, Java, Swift, Objective-C) and plugins with native code can't be patched.
  • Patches include arm64-v8a by default; add others with --abis. Devices with other ABIs keep the store build's code.
  • A patch is the whole compiled Dart library, compressed: often 3–10 MB.

Troubleshooting

Reason on the dashboardMeaning
base_mismatchThe device runs a different store build than the one recorded for the patch.
code_push_disabledallowCodePush is off in this build.
code_push_not_configuredMainActivity doesn't extend FireOTAFlutterActivity.
patch_not_loadedThe engine couldn't load the patch, so the app rolled back.
launch_not_confirmedThe patch crashed before its first frame and was rolled back.
signing_not_configuredThe app has no codeSigningCertificate.

Was this page helpful?