site-www
site-www copied to clipboard
Expand documentation of `late` considerations
I'm not exactly sure what this will look like yet, but I've been seeing a few misconceptions of the late keyword. The following are some common points of confusion or topics not well understood.
- When
lateis and isn't necessary - What
latemeans in different contexts - When
latecan be unsafe - How
late(variables) could potentially interact with other language features:- cascade notation (https://github.com/dart-lang/linter/issues/4873)
- immediately invoked anonymous functions (https://github.com/dart-lang/site-www/issues/4613)
- Late fields vs nullable fields
- When a factory makes sense instead of
latefields
If anyone has experienced any confusion around late themselves or seen it, please feel free to share as a comment here! I'd really appreciate it and it'd be super helpful to future Dart learners. Thanks!
Pretty sure I meet the target audience criteria and I just wanted to say the points you raised already are very in line with what I would consider helpful under the larger umbrella of learning when to reach for it, when not to, what my alternatives are and the tradeoffs I should consider.