website
website copied to clipboard
Navigator 2.0 example, with null safety
Page URL
https://docs.flutter.dev/development/ui/navigation
Page source
https://github.com/flutter/website/blob/main/src/development/ui/navigation/index.md
Describe the problem
The example linked to at the bottom of the page Learning Flutter’s new navigation and routing system - medium link by @johnpryan isn't updated for null safety.
The tutorial is good, but the code won't run, and auto-migrate doesn't work well because book
being null
was used as logic. I added a Book.empty()
constructor and Book.isEmpty()
method to capture the same idea.
Expected fix
- The medium page could be updated with a link to this dartpad:
https://dartpad.dev/?id=c43ef845b7c5b2b4527d939ef535c41a
- The flutter dev doc at https://github.com/flutter/website/blob/main/src/development/ui/navigation/index.md could have a link to a working example based on the same dartpad.
Additional context
Thanks @johnpryan for writing up the tutorial.
Was about to open an issue for the same. Instead of updating the medium article, the Navigator 2.0 article should be published on flutter.dev docs as well. Something like the Understanding Constraints page.
@johnpryan, can you weigh in on this? At the very least, we could add a note to the beginning of the article, explaining that it's out of date and where to go for the most up-to-date info.
I added a note to the top of the article, since we don't have the bandwidth to update all the sample code right now:
Note: The sample code in this article is not null-safe and not compatible with Dart 3. For more information on the latest best-practices for navigation and routing in Flutter, go to the Navigation and routing page on docs.flutter.dev.