restart_app icon indicating copy to clipboard operation
restart_app copied to clipboard

Do not call `exit` on Android or iOS

Open dnfield opened this issue 1 year ago • 4 comments

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.

dnfield avatar Feb 05 '24 22:02 dnfield

@dnfield did you pull request a solution?

kekko7072 avatar Feb 21 '24 09:02 kekko7072

any update?

Trung15010802 avatar Feb 23 '24 01:02 Trung15010802

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.

dnfield avatar Feb 23 '24 02:02 dnfield

@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!

bulwinkel avatar Apr 18 '24 02:04 bulwinkel

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.

gabrimatic avatar Sep 05 '24 14:09 gabrimatic