7 Flutter Routing In Depth
In this chapter:
- Setting up named routes
- Building routes on the fly
- Using the
Navigator
- Custom page transition animations
When I was planning out this chapter, I was trying to answer the question "Why?", or "Who cares?". This is one of the standard questions that Manning encourages their authors to think about before writing a chapter. And, well, this time it was pretty easy to answer: everyone who doesn’t want to make an app with a single page. Thus, a chapter on routing.
Routing can be a real pain on many platforms (but it shouldn’t have to be!). This point is all too clear in the web world. There are countless libraries that solely implement routing for different frameworks. And, speaking of the web world, I think the folks behind React Router nailed the solution. It’s easy to use, and it’s flexible. It matches the reactive and composable UI style of React.
According to their docs, they’re in the business of "dynamic routing", rather than static. Historically, most routing was declarative and routes were configured before the app rendered. The creators of React Router explained it well in their docs: "When we say dynamic routing, we mean routing that takes place as your app is rendering. Not in a configuration or convention outside of a running app." (reactrouter.com)