gabrimatic / restart_app

A Flutter plugin that helps you to restart the whole Flutter app with a single function call by using native APIs.
https://pub.dev/packages/restart_app
MIT License
72 stars 63 forks source link

Do not call `exit` on Android or iOS #23

Closed dnfield closed 1 month ago

dnfield commented 8 months ago

Calling exit is not safe in Flutter applications. It results in unpredictable shutdown/destruction of objects and crashes.

See e.g. https://github.com/flutter/flutter/issues/142835

Please consider updating your plugin to not call exit.

kekko7072 commented 7 months ago

@dnfield did you pull request a solution?

Trung15010802 commented 7 months ago

any update?

dnfield commented 7 months ago

I'm not sure I fully understand the use case for this plugin or how to achieve it's actual goal. Whatever it's goal is, calling exit isn't safe and will cause crashes sometimes.

bulwinkel commented 6 months ago

@dnfield My specific use case is with shorebird.dev to allow users to apply a patch. e.g. we detect a new patch is available, show an in app notification which if the user taps, it causes the app to restart applying the patch.

Given that scenario, do you know if there there a safe mechanism available to force the app's process to close? Happy to implement and open a PR.

Thanks in advance!

gabrimatic commented 1 month ago

In the new version 1.3.0, the exit method has been removed from Android restart. It is now using a new safe strategy to handle the native restart.

Unfortunately, there is no other way for iOS instead of using the exit method. Feel free to check this comment for more clarification.