showUpdateDialog static method

Future<PlayxVersionUpdateResult<bool>> showUpdateDialog({
  1. required BuildContext context,
  2. PlayxUpdateOptions options = const PlayxUpdateOptions(),
  3. PlayxUpdateUIOptions uiOptions = const PlayxUpdateUIOptions(),
  4. PlayxUpdateReminderOptions? reminderOptions,
})

Checks for an update and displays a platform-adaptive dialog or page if one is available.

This is the simplest way to prompt users to update. The function first calls checkVersion using the provided options. If an update is available, it presents a UI:

  • A Material dialog on Android.
  • A Cupertino dialog on iOS.

For forced updates, you can configure it to show a full-screen PlayxUpdatePage instead of a dialog by setting showPageOnForceUpdate in uiOptions.

This method is ideal for a standard, non-intrusive update prompt on any platform.

Parameters:

  • context: The BuildContext required to show the dialog or page.
  • options: Configuration for the version check itself, like store IDs or providing a manual version to check against.
  • uiOptions: Configuration for the look and feel of the update UI, including titles, descriptions, and button callbacks.
  • reminderOptions: Optional. Remembers when the user chose "Later" or "Skip this version" and does not prompt again for that version until the snooze ends. Forced updates are never suppressed.

Returns:

A PlayxVersionUpdateResult with a bool. On success, the bool is true when the update UI was triggered, and false when an update is available but the prompt was suppressed by reminderOptions. It does not wait for the user to interact with the dialog.

Example:

await PlayxVersionUpdate.showUpdateDialog(
  context: context,
  options: PlayxUpdateOptions(
    googlePlayId: 'com.example.app',
    appStoreId: 'com.example.app',
  ),
  uiOptions: PlayxUpdateUIOptions(
    title: (info) => 'Update Available!',
    description: (info) => 'A new version ${info.newVersion} is ready. We recommend updating to the latest version to enjoy new features and bug fixes.',
  ),
);

@see showInAppUpdateDialog for handling native Android in-app updates. @see PlayxUpdateOptions and PlayxUpdateUIOptions for all available configurations.

Implementation

static Future<PlayxVersionUpdateResult<bool>> showUpdateDialog({
  required BuildContext context,
  PlayxUpdateOptions options = const PlayxUpdateOptions(),
  PlayxUpdateUIOptions uiOptions = const PlayxUpdateUIOptions(),
  PlayxUpdateReminderOptions? reminderOptions,
}) async {
  final result = await checkVersion(options: options);
  // `context.mounted` is checked inside, after the reminder lookup.
  // ignore: use_build_context_synchronously
  return _showUpdateUI(context, result, uiOptions, reminderOptions);
}