Import package:restart_app/restart_app.dart to use these types.

Restart.restartApp

Requests a restart or web reload and returns a Future<RestartResult>.
The default behavior depends on the platform. Pass mode to request another supported behavior. See configuration for parameter defaults and examples. If your app has unsaved data, finish and await those writes before calling. The request can stop the Dart isolate or unload the browser document before later code finishes.

Web destinations

On web, only RestartMode.platformDefault is supported. webOrigin determines the destination: Relative URLs resolve against document.baseURI, including an HTML <base href> element. URLs match the same document when they are equal after removing their fragments. The default reload does not change the URL to your app’s initial route. An app embedded in an iframe reloads its own frame.

Restart.restartCapability

Returns a Future<RestartCapability> describing which restart behaviors the platform provides.
Use it to decide which restart options to show. These capabilities do not guarantee that a request will succeed: for example, an iOS engine restart also needs the app to be active and have a suitable window. Web supports the default reload even though its process, engine, and notification flags are all false. Missing plugin registration and platform-channel errors return unavailable capabilities. The reason field explains the failure when an explanation is available.

RestartMode

RestartResult

Native platforms may perform the restart after sending a successful result. A failure during that later work is written to native logs and cannot change the result already returned to Dart.

RestartCapability

Failures

Platform errors are returned as RestartResult values with success: false. Read code and message to decide how your app should respond. Send one restart request per user action. Disable repeated taps as soon as the action starts. If the request fails, show the failure and let the user try again after addressing its cause. Call from the main isolate. If you invoke the API before runApp, first call WidgetsFlutterBinding.ensureInitialized(). See background isolates for worker coordination.