I have a test case where I want to imitate restarting app during the test (because I know that it's impossible to kill the app and reopen it). Then I just want to check if some state is persisted.
I tried search for it in the patrol API but haven't found anything.
Restarting the whole app during a test is currently not possible in Patrol. It's tracked here. Restarting the Dart-side is also not possible, at least I do not know about it. What you can do, though, is restart the Flutter widget tree.
You can do it by attaching the root widget again, e.g. calling runApp()
again, or by triggering a rebuild of a top-most widget in the tree (by e.g. changing its key). If your app's state lives in the widget tree (which is the case if you're using e.g. bloc
), it will be reset.
Be aware that this is not a "full restart" of the Dart program state, but merely of the Flutter widget tree. If you have some global mutable state, it will not be reset, and you'll likely face strange problems.