Wednesday, March 31, 2021

Flutter Navigation: flutter_modular or stacked?

The current way of Flutter Widgets Explorer using switch statement to construct the main listing screen and navigation no longer sustainable as I foreseen the number of showcases will be double or triple in the coming months.

Hence, I decided to look into new solution. First, I come across an article shared about Flutter Navigation 2.0. In my opinion, it is too complex, we need better abstraction to make it usable to developers. I search again and finally nailed down to two alternatives: flutter_modular and stacked.

Let's look at simple code metrics (line of codes) for both packages:

















It is obvious that flutter_modular is the winner here. It has less boilerplate code and code generation is not required. For stacked, it still has more line of codes compared to flutter_modular after excluding the generated app.router.dart and app.locator.dart. Also, flutter_modular using Navigation 2.0 and stacked still using Navigation 1.0 if I'm not wrong (Correct me if I'm wrong).

Lastly, there's one pending issue for Flutter Widgets Explorer to adopt flutter_modular as it's navigation library, the default back button is missing, I opened an issue that still pending for response at the time of writing.

If you interested to dig into the code, feel free to look into the github repo for flutter_modular and stacked implementation.

Happy coding! :)

Like this blog?

Thanks for visiting! If you like what you see, I'd really appreciate you linking to it or otherwise sharing it with people you think would find it useful.

No comments: