h0102
h0102

Reputation: 256

Handle activity get destroyed in Flutter App

When turning on "Don't keep activities in the Android developer options, the navigation route stack of Flutter app seems to be cleared and the Android app shows the first screen like a fresh start.

What is the proper way to keep or restore the navigation route stack in Flutter Android app?

Upvotes: 7

Views: 1247

Answers (1)

Omatt
Omatt

Reputation: 10519

You shouldn't depend on the Screen to retain the displayed data since this can be destroyed. You can explore app state management available in Flutter. Using provider plugin is one of the simple ways of managing app state as demonstrated in this guide.

As for tracking the Navigation history, you can keep track of it in a List<String> if you're using named routes.

Upvotes: 0

Related Questions