performForceUpdate static method

Future<void> performForceUpdate(
  1. BuildContext context, {
  2. required String androidStoreUrl,
  3. required String iosStoreUrl,
  4. bool? barrierDismissible,
  5. String dialogTitle = 'Required Update',
  6. String dialogMessage = 'A critical update is required to continue using the app. Please update now to the latest version.',
  7. String updateButtonText = 'Update Now',
  8. String laterButtonText = 'later',
})

Performs the actual forced update process (displaying the dialog and enforcing exit).

This function MUST be called only if checkForUpdate returns true. It is safe to call from initState as it wraps the logic in a post-frame callback.

context is required to display the dialog.

Implementation

static Future<void> performForceUpdate(
  BuildContext context, {
  required String androidStoreUrl,
  required String iosStoreUrl,
  bool?
      barrierDismissible, // Optional: Allow dismissing dialog by tapping outside
  String dialogTitle = 'Required Update',
  String dialogMessage =
      'A critical update is required to continue using the app. Please update now to the latest version.',
  String updateButtonText = 'Update Now',
  String laterButtonText = 'later', // display when barrierDismissible is true
}) async {
  // Determine the correct store URL
  final storeUrl = Platform.isIOS ? iosStoreUrl : androidStoreUrl;

  // Display the unified dialog
  _showForceExitDialog(context, barrierDismissible, dialogTitle,
      dialogMessage, updateButtonText, laterButtonText, storeUrl);
}