restart 1.0.0+1 copy "restart: ^1.0.0+1" to clipboard
restart: ^1.0.0+1 copied to clipboard

A Flutter plugin to restart the application. The plugin works by restarting the Flutter Engine, instead of the underlying native application.

restart #

A Flutter plugin to restart the application.

The plugin works by creating a new instance of the Flutter Engine. The entry point of the Dart VM is executed again, while the underlying platform specific application keeps running. This is achieved as follows:

Android #

Recreating the FlutterActivity.

iOS #

Creating a new instance of FlutterViewController & setting it as root view controller of the UIApplication.

Installation #

Add package to the dependencies section of the pubspec.yaml:

dependencies:
  restart: ^1.0.0

Documentation #

A single method call allows to terminate the Dart VM & restart execution from the entry point.

import 'package:restart/restart.dart';

// 🎉
restart();

Setup #

Android #

No changes required.

iOS #

Flutter plugins must be registered again with the newly created Flutter Engine. Modify the ios/Runner/AppDelegate.swift file in your Flutter project as follows:

 import Flutter
 import UIKit
+import restart

 @UIApplicationMain
 @objc class AppDelegate: FlutterAppDelegate {
     override func application(
         _ application: UIApplication,
         didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
     ) -> Bool {
+        // --------------------------------------------------
+        RestartPlugin.generatedPluginRegistrantRegisterCallback = { [weak self] in
+            GeneratedPluginRegistrant.register(with: self!)
+        }
+        // --------------------------------------------------
         GeneratedPluginRegistrant.register(with: self)
         return super.application(application, didFinishLaunchingWithOptions: launchOptions)
     }

 }
14
likes
160
pub points
87%
popularity

Publisher

verified publisherfarmako.in

A Flutter plugin to restart the application. The plugin works by restarting the Flutter Engine, instead of the underlying native application.

Repository (GitHub)
View/report issues

Topics

#restart

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on restart