How Can I Restart My Flutter App With Getx

Viewed 1538

I am using the getx package in my application and there is something I am wondering about. Is it possible to reset all states of my app using getx? So it's kind of like a restart.

2 Answers
    Future<void> logoutUser() async {

    SharedPreferences prefs = await SharedPreferences.getInstance();
    prefs.clear(); //clearing my token data
    await Get.deleteAll(force: true); //deleting all controllers
    Phoenix.rebirth(Get.context!); // Restarting app
    Get.reset(); // resetting getx

  }

used flutter_phoenix library to resart the app. Deleted all controllers using Get.deleteAll(force: true);

Works like a charm for me.

Yes. There is. You can call Get.reset() to hot restart your app.

Related