airbuild_code_push library

AirBuild CodePush for Flutter — a thin wrapper around Shorebird's shorebird_code_push package for apps distributed through an AirBuild-hosted (or self-hosted) control plane.

This is a separate library from package:airbuild/airbuild.dart (the binary-distribution SDK) because it pulls in the shorebird_code_push dependency, which requires the Shorebird updater runtime to be compiled into your app (via shorebird release/shorebird patch, not a plain flutter build). Only import this if you're using AirBuild CodePush.

Usage:

import 'package:airbuild/airbuild_code_push.dart';

final codePush = AirBuildCodePush();

// Check for a patch (don't await this during app startup — see the
// shorebird_code_push docs on why).
codePush.checkForUpdate().then((status) {
  if (status == UpdateStatus.outdated) {
    codePush.update();
  }
});

For a zero-effort integration that handles check → download → restart-prompt itself (with auto_update: false in shorebird.yaml), wrap your app in AirBuildCodePushOverlay:

MaterialApp(
  builder: (context, child) => AirBuildCodePushOverlay(
    config: AirBuildCodePushConfig(onRestart: () => restartMyApp()),
    child: child ?? const SizedBox.shrink(),
  ),
  home: const HomePage(),
);

For this to talk to your AirBuild server instead of Shorebird's cloud, your shorebird.yaml must point base_url at it:

# shorebird.yaml
app_id: <your-shorebird-app-id>
base_url: https://airbuild.dev

See docs/guides/flutter-codepush.md for the full setup guide, including how releases/patches are created via the airbuild CLI.

Classes

AirBuildCodePush
A thin, AirBuild-branded wrapper around Shorebird's ShorebirdUpdater.
AirBuildCodePushConfig
Configuration for AirBuildCodePushOverlay.
AirBuildCodePushOverlay
A drop-in widget that runs the whole manual CodePush lifecycle for you: it checks for a patch on launch (optionally periodically and on resume), downloads it, and shows a "restart to apply" banner once staged.
AirBuildCodePushOverlayState
State for AirBuildCodePushOverlay. Exposed so apps can read status and trigger checkNow via AirBuildCodePushOverlay.maybeOf.
Patch
An object representing a single patch (over-the-air update).

Enums

UpdateFailureReason
The reason a call to ShorebirdUpdater.update failed.
UpdateStatus
The current status of the app in terms of whether its up-to-date.

Extension Types

UpdateTrack
A track to check for updates on.

Constants

playStorePackageName → const String
The package name Google Play installs apps under — the value returned by PackageManager.getInstallSourceInfo().installingPackageName for Play-installed apps.

Functions

installerPackageName() → Future<String?>
The package name of the app/store that installed this app on the device (Android only).
isPlayStoreInstall() → Future<bool>
Whether this running build was installed from the Google Play Store.
showRestartBanner(BuildContext context, {required OnRestartCallback onRestart, String message = 'An update has been downloaded and will apply on restart.'}) → void
Shows a MaterialBanner telling the tester a patch has been downloaded and will apply on the next restart, with a "Restart now" action.

Typedefs

CodePushBannerBuilder = Widget Function(BuildContext context, VoidCallback? onRestart, VoidCallback onDismiss)
Builds the "restart to apply" banner shown by AirBuildCodePushOverlay.
OnRestartCallback = void Function()
Called when the tester taps "Restart now" on showRestartBanner. The SDK deliberately doesn't restart the app itself — Flutter has no built-in "restart the process" API, and the right mechanism varies by app (a Restart.restartApp()-style package, popping back to a root widget and rebuilding it, or simply asking the user to close and reopen manually). Provide whichever of those your app already uses.

Exceptions / Errors

ReadPatchException
An exception thrown by ShorebirdUpdater.readCurrentPatch and ShorebirdUpdater.readNextPatch when the read is unsuccessful.
UpdateException
An exception thrown by ShorebirdUpdater.update when the update is unsuccessful.