skip to Main Content

How can I restart the app in Flutter and call the main again?

I tried Phoenix.rebirth(context) but the main is not called again

2

Answers


  1. Luckily there’s a plugin called phoniex to do it https://pub.dev/packages/flutter_phoenix sadly it only works on iOS.

    Try this restart_app plugin
    A simple package that helps you to restart the whole android app with a single function call. It supports android only

    If you need to restart the app for both android and iOS. You can give it a try from the below-mentioned code

    void restartApp(BuildContext context) {
      if (Platform.isAndroid) {
        Restart.restartApp();
      } else {
        Phoenix.rebirth(context);
      }
    }
    
    
    Login or Signup to reply.
  2. Use restart_app flutter package.

    How to use it?
    1. Add the package to pubspec.yaml dependency:
    dependencies:
      restart_app: ^1.1.2
    
    1. Import package:
    import 'package:restart_app/restart_app.dart';
    
    1. Call the restartApp method where ever you want:
    onPressed: () {
      /// Fill webOrigin only when your new origin is different than the app's origin
      Restart.restartApp(webOrigin: '[your main route]');
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search