Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Conversation

@srawlins
Copy link
Contributor

There are a few issues with the text, which I fix here:

  • the example used a class with a non-nullable field with no initializer,
  • the example did not specify a parameter type for operator ==; in Dart versions before null safety, this parameter type was dynamic (I think), but after null safety, it is Object, so even aside from this lint rule, comparing to null wouldn't make sense.
  • incorrect text in the first sentence summary.

@github-actions github-actions bot added the linter-set-recommended Affects a rule in the recommended Dart rule set label Dec 14, 2022
@coveralls
Copy link

Coverage Status

Coverage remained the same at 95.637% when pulling 7aea615 on fix-compare-null-examples into ef46492 on main.

@override
operator ==(other) => other is Person && name == other.name;
operator ==(Object? other) => other is Person && name == other.name;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Best practice is for the parameter to be Object because a null can't be passed in. (I haven't checked to see whether we have another warning for that.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha I know. But the lint won't fire under that practice.

@srawlins srawlins merged commit b4c66e8 into main Dec 14, 2022
@srawlins srawlins deleted the fix-compare-null-examples branch December 14, 2022 21:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

linter-set-recommended Affects a rule in the recommended Dart rule set

Development

Successfully merging this pull request may close these issues.

5 participants