The popular Fluro package for Flutter allows devs to pass arguments between Flutter pages via the route string. For example:
collection/289/item/1224?view=grid
Why are people doing this? There are a number of disadvantages of this approach relative to passing arguments via objects:
- You lose compile-time type enforcement for all arguments that aren't ultimately strings. You have to typecast somewhere.
- You have to reference objects by ID and look them up by ID instead of just getting the object directly. You have to manage unique IDs for objects that wouldn't otherwise have them, and you may need to also cache remotely loaded objects so they're not reloaded on page change.
I can think of the following possible advantages of passing all arguments via the route:
- If Flutter eventually supports Android's ability to kill and restart an app in the background, the app could restart on the same page merely by knowing the route. The Flutter team may decide to use the route for this purpose.
- If you plan to share code between mobile and web versions of your app, by making each mobile page stateless, you're better positioned for doing so.
Neither of these advantages is realized today. The Flutter team has not decided how to restart Android apps (to my knowledge), and Flutter Web is still too buggy and slow for production.
So why are people actually passing arguments via the route? Why are people using packages such as Fluro? Is it just for potential future benefit, or are they realizing benefit now?
(I'm trying to plan how I should structure my own apps.)