FlutterPatcher class Architecture API-reference Crash-protection
Flutter hot-update entrypoint for Android and iOS.
flutter_patcher installs patch files on hosts built with
flutter_patcher build android|ios, and loads them on the next cold start.
SO and bytecode hosts share this API; iOS hosts are bytecode only.
Main APIs:
- init: configure crash protection and first-frame boot verification.
- applyPatchBytes / applyPatchFile: install a patch file the app obtained in any way, such as from its own server; patchTarget names the file this host needs.
- checkUpdate and applyPatch: a built-in downloader for patch files placed at a URL.
- rollback: delete the current patch.
Patches are never swapped into the current process. A successful apply takes effect only after the next cold start.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
-
applyProgress
→ Stream<
PatchApplyProgress> -
Broadcast progress stream for applyPatch.
no setter
-
appVersionCode
→ Future<
int?> -
Host build number: Android versionCode, iOS CFBundleVersion. Returns null
on failure or an unsupported platform.
no setter
-
blacklist
→ Future<
List< BlacklistEntry> > -
Local bad-patch blacklist: patches whose starts failed
maxCrashCounttimes, or whose code threw after it started (see init).no setter -
currentVersion
→ Future<
String?> -
Patch version currently installed on disk.
no setter
- debugAssumeSupported ↔ bool
-
Lets tests on a desktop host call the API as on a device.
getter/setter pair
-
deviceAbi
→ Future<
String> -
Current device ABI (
arm64-v8a,ios-arm64). Useful when your backend routes patches per ABI.no setter -
lastBootDiagnostic
→ Future<
PatchBootDiagnostic?> -
Last cold-start patch loading diagnostic.
no setter
-
patchTarget
→ Future<
PatchTarget> -
Who this host is: the patch PatchTarget.fileName it installs, its
build and the sequence it accepted last. An app that fetches patch
files itself sends these to its server to pick the right file.
no setter
Static Methods
-
applyPatch(
PatchInfo patchInfo, {void onProgress(PatchApplyProgress)?}) → Future< PatchApplyResult> - Applies the update checkUpdate returned: downloads the patch file, then native code verifies and installs it for the next cold start, as applyPatchBytes does. A withdrawal removes the installed patch.
-
applyPatchBytes(
List< int> bytes) → Future<PatchApplyResult> -
Installs the patch file
bytes, or applies the withdrawal it is, for the next cold start. Native code verifies the whole file: that it is this host's, intact, signed when the host trusts a key, and numbered above every file the host accepted. -
applyPatchFile(
String path) → Future< PatchApplyResult> -
Installs the patch file at
pathas applyPatchBytes does. The file stays where it is. -
checkUpdate(
{String? url, Duration timeout = const Duration(seconds: 10)}) → Future< PatchCheckResult> -
Checks for a patch file at
url:GET <url>/<fileName>, wherefileNameis this host's PatchTarget.fileName and the file is whatflutter_patcher patchorpublishwrote. By defaulturlis the addressbuildwrote into the app:urlinflutter_patcher.yaml, orhttp://127.0.0.1:8686, whereflutter_patcher serveoffers patches while developing. -
clearBlacklist(
) → Future< void> - Clears the local bad-patch blacklist.
-
init(
{int maxCrashCount = 1, List< String> loaderFieldCandidates = const ['flutterLoader'], bool loaderFallbackHeuristic = false, Duration verifyAfter = const Duration(seconds: 5)}) → Future<void> -
Configures crash protection. A patched start is confirmed natively at
its first frame; uncaught Dart errors still count as a failed start for
verifyAfterafter it. -
inspectPatch(
List< int> header) → Future<PatchInspection> -
Whether a patch file starting with
header, its first 146 bytes or more, is new to this host, before downloading the rest. Installing the file still verifies all of it. -
rollback(
) → Future< void> - Deletes the current patch. The next cold start runs the app's built-in version. Manual rollback does not blacklist the patch.