-
Notifications
You must be signed in to change notification settings - Fork 704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adds null safety codelab #2983
adds null safety codelab #2983
Conversation
(CC @RedBrogdon) |
fixes headings
null_safety_examples/null_safety_codelab/bin/more_nullable_types.dart
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with some comments
null_safety_examples/null_safety_codelab/bin/conditional_access.dart
Outdated
Show resolved
Hide resolved
null_safety_examples/null_safety_codelab/bin/late_circular_references.dart
Outdated
Show resolved
Hide resolved
null_safety_examples/null_safety_codelab/bin/promotion_exceptions.dart
Outdated
Show resolved
Hide resolved
…s.dart Co-authored-by: Filip Hracek <[email protected]>
Co-authored-by: Filip Hracek <[email protected]>
Co-authored-by: Filip Hracek <[email protected]>
Co-authored-by: Kathy Walrath <[email protected]>
Co-authored-by: Kathy Walrath <[email protected]>
Co-authored-by: Kathy Walrath <[email protected]>
Co-authored-by: Kathy Walrath <[email protected]>
Co-authored-by: Kathy Walrath <[email protected]>
Co-authored-by: Kathy Walrath <[email protected]>
Co-authored-by: Kathy Walrath <[email protected]>
Co-authored-by: Kathy Walrath <[email protected]>
Co-authored-by: Kathy Walrath <[email protected]>
Co-authored-by: Kathy Walrath <[email protected]>
Co-authored-by: Kathy Walrath <[email protected]>
Co-authored-by: Kathy Walrath <[email protected]>
thanks. i remember clicking the commit button for each suggestion. but i see now that i need to wait for the page to reload each time. |
mit said that i could skip a second review from him.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed a few more things, but I need to take another look with fresh eyes... tomorrow, I hope!
One more thing that I didn't notice until just now: the line between examples and exercises doesn't seem clear in this codelab. I think of examples as being things you can just run without modification, but I think every one of these DartPads except for final one ("Exercise: Late and lazy") requires some code changes.
Maybe they should all be examples? All except the last one exercises? Or maybe we should add a suggestion for how they could modify the last one?
In https://dart.dev/codelabs/async-await, exercises have a dark background and examples have a white background, but since the changes required here are so minor, differentiating the backgrounds seems perhaps unnecessary.
Copy edit-level stuff, plus changed the last example slightly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're ready to go. I'll file a bug for follow-up work, like adding this to the /codelabs page and perhaps adding hints & tests to the examples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, but some minor comments that can be implemented in a followup PR.
List<String> aListofStrings = ['one', 'two', 'three']; | ||
List<String?> aNullableListOfStrings = []; | ||
List<String?> aListofNullableStrings = ['one', null, 'three']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like of
should be Of
to be consistent with the middle declaration and general naming standards.
late String description; | ||
|
||
void setDescription(String str) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems very not "Dart" like to include a setter method like this. Perhaps you could switch this example to use a getter and setter:
Late variables aren't generally a good idea to expose publicly anyway as you don't have much control over what others will do.
class Meal {
late String _description;
void set description(String str) => _description = str;
String get description => _description;
}
void main() {
final myMeal = Meal();
myMeal.description = 'Feijoada!';
print(myMeal.description);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Goodness, this sounds reasonable but we might need to think about it. I'll add it to that follow-up issue.
Co-authored-by: Parker Lougheed <[email protected]>
staging: https://rm-dart.firebaseapp.com/codelabs/null-safety