IssueRaiser

add restartApp() method

### Is there an existing issue for this? - [X] I have searched the [existing issues](https://github.com/flutter/flutter/issues) - [X] I have read the [guide to filing a bug](https://flutter.dev/docs/resources/bug-reports) ### Use case There is no canonical way to restart a flutter app in production. This is useful as part of a state clearing routine. There are multiple methods, but they all have drawbacks, and none of them are canonical Why: - Useful for integration testing - Customer care troubleshooting - Allow user to get fresh state without uninstalling app - Auto reset app state if there is a crash loop on launch Proposal: - add a `restartApp()` method to go with `runApp()` Functionality: - relaunches the flutter instance with fresh state - does not reset stored state (shared_preferences, sqlite, etc) - does not quit the native app Community suggestions: - use runApp() again -> no-op in testing - send SIGUSR2 -> doesn't work in prod - swap a GlobalKey on top level widget -> doesn't work for all DI systems - `flutter_phoenix` -> GlobalKey method Ethos argument: This is a primitive action that should be dependable, reliable, and opinionated Community feedback in support: - https://twitter.com/peteralexbizjak/status/1660962150288965632 - https://twitter.com/wamweaaa/status/1660894603321516034 - https://twitter.com/mwhmyers/status/1661040773461319681 - https://twitter.com/yasinilhan/status/1661079434881802241

Posted by lukepighetti on May 23, 2023, 5:15 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.2,500 issues0 comments

reliability (SaaS)

add restartApp() method

lukepighettiMay 23, 2023, 5:15 PM

### Is there an existing issue for this? - [X] I have searched the [existing issues](https://github.com/flutter/flutter/issues) - [X] I have read the [guide to filing a bug](https://flutter.dev/docs/resources/bug-reports) ### Use case There is no canonical way to restart a flutter app in production. This is useful as part of a state clearing routine. There are multiple methods, but they all have drawbacks, and none of them are canonical Why: - Useful for integration testing - Customer care troubleshooting - Allow user to get fresh state without uninstalling app - Auto reset app state if there is a crash loop on launch Proposal: - add a `restartApp()` method to go with `runApp()` Functionality: - relaunches the flutter instance with fresh state - does not reset stored state (shared_preferences, sqlite, etc) - does not quit the native app Community suggestions: - use runApp() again -> no-op in testing - send SIGUSR2 -> doesn't work in prod - swap a GlobalKey on top level widget -> doesn't work for all DI systems - `flutter_phoenix` -> GlobalKey method Ethos argument: This is a primitive action that should be dependable, reliable, and opinionated Community feedback in support: - https://twitter.com/peteralexbizjak/status/1660962150288965632 - https://twitter.com/wamweaaa/status/1660894603321516034 - https://twitter.com/mwhmyers/status/1661040773461319681 - https://twitter.com/yasinilhan/status/1661079434881802241

Comments (0)

No comments yet. Start the discussion.

Comment on this issue