website icon indicating copy to clipboard operation
website copied to clipboard

[PAGE ISSUE]: 'Pass arguments to a named route'

Open cnmade opened this issue 3 years ago • 5 comments

Page URL

https://docs.flutter.dev/cookbook/navigation/navigate-with-arguments/

Page source

https://github.com/flutter/website/tree/main/src/cookbook/navigation/navigate-with-arguments.md

Describe the problem

The document show example may be not null safety

Expected fix

Add null safety check passing arguments.

Additional context

No response

cnmade avatar Jun 15 '22 09:06 cnmade

Hi @cnmade, what part of the cookbook do you think is not null safe?

danagbemava-nc avatar Jun 15 '22 12:06 danagbemava-nc

For a real-world app powered by flutter, we may have two scenarios

  1. may pass arguments
  2. may not pass arguments or pass null

My real-world code looks like

image

In scenario 1, we pass arguments, then we can get args, which have values.

In scenario 2, we have null, args == null, and we use the default value to display the variable.

ghost avatar Jun 15 '22 13:06 ghost

I thought the document should cover more real world. May the passing argument be null ? how can we handle with Null ? Document should provided good example to show the power.

ghost avatar Jun 16 '22 01:06 ghost

I think I get your point, but for the record, the example is null-safe.

Improving the example to show how to handle/deal with missing/null parameters may be good overall for beginners.

danagbemava-nc avatar Jun 16 '22 12:06 danagbemava-nc

The document told us:

1 + 1 = 2

The real world case:

image

me be like:

image

ghost avatar Jun 16 '22 13:06 ghost

These examples are null safe. Closing this issue.

atsansone avatar May 30 '23 19:05 atsansone