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:

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 maxCrashCount times, 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 path as 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>, where fileName is this host's PatchTarget.fileName and the file is what flutter_patcher patch or publish wrote. By default url is the address build wrote into the app: url in flutter_patcher.yaml, or http://127.0.0.1:8686, where flutter_patcher serve offers 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 verifyAfter after 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.