restart method

  1. @override
Future<bool> restart({
  1. required bool killProcess,
  2. required bool wipeData,
  3. required bool keepSecureStorage,
  4. required bool keepPreferences,
})
override

Performs the restart.

  • killProcess: true for a full process restart, false for a UI-only restart.
  • wipeData: delete app data before restarting.
  • keepSecureStorage: when wiping, keep keychain / secure storage.
  • keepPreferences: when wiping, keep preferences (UserDefaults, SharedPreferences, localStorage).

Completes with true once the platform has accepted the request.

Implementation

@override
Future<bool> restart({
  required bool killProcess,
  required bool wipeData,
  required bool keepSecureStorage,
  required bool keepPreferences,
}) async {
  try {
    if (wipeData) {
      await _wipeBrowserData(
        keepSecureStorage: keepSecureStorage,
        keepPreferences: keepPreferences,
      );
    }
    // Reload in a microtask so this Future completes first.
    // `location.replace(sameUrl)` does not reload in most browsers, so
    // both restart types use `reload()`.
    scheduleMicrotask(() => web.window.location.reload());
    return true;
  } catch (_) {
    return false;
  }
}