SimpleRoutes
Background
When developing Flutter applications, I prefer to use the go_router package for navigation. While it is an excellent library, there are some areas that I felt required a lot of boilerplate code or created opportunities for runtime errors. Two of the biggest pain-points I identified were:
The use of “magic strings” for route paths
No compile-time, type-safe URL parameter enforcement
If I defined a route, “users/:id”, I would need to use that exact path when navigating or it would fail at runtime.
Additionally, when navigating, I would need to know what parameters were required. If I got it wrong, navigation would, again, fail at runtime.
Solution
After some experimentation, I developed the simple_routes package to solve these pain-points and make navigation in Flutter, well… simple.
By using classes to define your routes and then allowing the library to handle navigation and enforcing path parameters at compile time, you no longer have to worry about “just knowing” what to do. Instead, SimpleRoutes tells you what is necessary and handles the rest for you.
Check out the pub.dev listing, read my blog post, or try it out in your own application!
Photo by Glenn Carstens-Peters on Unsplash