website icon indicating copy to clipboard operation
website copied to clipboard

Navigator 2.0 example, with null safety

Open chonghorizons opened this issue 3 years ago • 2 comments

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

  1. The medium page could be updated with a link to this dartpad:

https://dartpad.dev/?id=c43ef845b7c5b2b4527d939ef535c41a

  1. 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.

chonghorizons avatar Dec 09 '21 08:12 chonghorizons

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.

Mayank-9018 avatar Dec 11 '21 08:12 Mayank-9018

@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.

sfshaza2 avatar May 26 '22 17:05 sfshaza2

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.

johnpryan avatar Jun 05 '23 16:06 johnpryan