New post on /r/flutterdev subreddit:
My Favorite Navigator 2.0 Package: Routemaster
Hey All,I'm upgrading a large app to Flutter 2.2 with Null safety. It runs on web, so I was excited to dig into Navigator 2.0 to handle things like query parameters, deep linking, and nesting more effectively than I was (not at all).I quickly realized after completing this
Flutter Navigator 2 tutorial that coding this all from Scratch would be way to complicated. That there must be a package that abstracts away all the needless boilerplate. Turns out there are quite a few to pick from.Flutter Team is aware of the issue of too many choices, how complex Navigator 2 is, and is evaluating implementations as well.
https://github.com/flutter/uxrI'm posting my thoughts here in case you're facing the same issue as me where you don't know where to start or what these packages are like IRL.I have tried the following.
VRouterI was attracted to the great documentation (even built using VRouter), but I quickly hit a wall. They require you to replace MaterialApp() with VRouter() or VMaterialApp(), but neither of these support the parameter scaffoldMessengerKey which I need for global snackbars without context. It seemed like a hard to maintain architecture decision to need to have this plugin gatekeeping MaterialApp / MaterialApp.router features. So I bailed on it.
BeamerThis was the other most popular Navigator plug in. The documentation is harder to understand. Beamer is opinionated on how it approaches navigation conceptually. You have to understand their ideas and how they see things. It works great, and may be great for very complex navigation problems. But the learning curve is high, just making sense of their terminology and "beaming" to and from "beam locations" is too much.I have ~25 screens with some nesting / tabs to handle, with lots of potential query parameter points in the URL's. I don't have to map out the URL schema of an entire social network or ecommerce system and "virtually teleport" the user throughout "beam locations". So this was more complicated than I needed, and overkill.
Routemaster 🔔I tried this third, someone on twitter recommended it. It came a few percentage points behind Beamer and VRouter in terms of popularity on
pub.dev. But still pretty high up there.I can't believe how simple it is to implement, and how well it works. I built out my routes in a route file (including how to handle query parameters throughout the urls). I added Guards with simple bool functions to evaluate sending the user to the screen or an error screen. I feel like I didn't even have to learn anything, it all just naturally fits into how flutter works, and how I expect URL's and navigation on the web to work. It's honestly easier to implement than Navigator 1.0. Changing routes with or without context is dead simple.I'm super happy I found Routemaster.
September 02, 2021 at 05:20AM by boon4376
https://ift.tt/2WQDPDP