migrate localization to null safety#84064
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
darrenaustin
left a comment
There was a problem hiding this comment.
@Abhishek01039 thanks so much for the contribution. I have a few comments that need to be addressed before we can land this.
|
|
||
| final Set<String> keys = Set<String>.from( | ||
| resources.keys.where((String key) => !isPluralVariation(key)) | ||
| resources!.keys.where((String key) => !isPluralVariation(key)) |
There was a problem hiding this comment.
I think what @goderbauer was getting at is that here (line 125) we are assuming that resources is not null. If that is always the case then we should make resources non-nullable. If it can be null then the initialization for keys here needs to take that into account. Given that the existing code works with keys being initialized as they are I think we can assume it is not null.
| final List<String> missingKeys = <String>[]; | ||
| for (final String missingKey in canonicalKeys.difference(keys)) { | ||
| final dynamic attribute = attributes[missingKey]; | ||
| for (final String? missingKey in canonicalKeys.difference(keys)) { |
There was a problem hiding this comment.
If canonicalKeys is defined as Set<String> as mentioned above, then neither missingKeys or missingKey here would need to use nullable strings here.
darrenaustin
left a comment
There was a problem hiding this comment.
Thanks for the update, but it looks like you missed the resources being non-null in localizations_validator.dart. Please update that and I think we will be good to go. Thx.
|
Thanks @darrenaustin |
part of #84014