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
| Android | iOS | |
|---|---|---|
| Dart code patches | Yes (opt-in) | No |
| Asset and remote-config updates | Yes | Yes |
| Signing, staged rollouts, automatic rollback | Yes | Yes |
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
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.dartwith your app ID, server URL and channel. - Starts FireOTA in
main()beforerunApp. - Makes
MainActivityextendFireOTAFlutterActivity, which starts the engine with the installed patch.
Or set it up by hand:
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(),
);// 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.
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)
- 1Create a signing key with
fireota signing generate. Add the public key under Code signing and tocodeSigningCertificate. Code patches are always signed. - 2Build 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"
- 3Upload
build/app/outputs/bundle/release/app-release.aabto Google Play as usual. - 4Change 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)
fireota flutter assets --platform all --app YOUR_APP_ID \ --assets ./ota-assets --config ./config.json --message "Holiday theme"
FireOTAImage('assets/banner.png') // updated file, or the bundled asset
final theme = FireOTA.config['theme']; // remote config from config.jsonAsset updates apply on the next start on Android. On iOS, FireOTA.restart() switches them in place.
Store policy
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-v8aby 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 dashboard | Meaning |
|---|---|
base_mismatch | The device runs a different store build than the one recorded for the patch. |
code_push_disabled | allowCodePush is off in this build. |
code_push_not_configured | MainActivity doesn't extend FireOTAFlutterActivity. |
patch_not_loaded | The engine couldn't load the patch, so the app rolled back. |
launch_not_confirmed | The patch crashed before its first frame and was rolled back. |
signing_not_configured | The app has no codeSigningCertificate. |
Was this page helpful?