felangel / equatable

A Dart package that helps to implement value based equality without needing to explicitly override == and hashCode.
https://pub.dev/packages/equatable
MIT License
901 stars 100 forks source link

Update README.md to use List<Object?> #136

Closed noamraph closed 2 years ago

noamraph commented 2 years ago

I tried to add Equatable to a class I have according to the readme, and it failed because I had a nullable field. Replacing List<Object> with List<Object?> fixed the problem. So I suggest to change the readme.

The actual overridden property is indeed List<Object?> get props, so I think there's no need to restrict it to non-nullable values.

Status

READY/IN DEVELOPMENT/HOLD

Breaking Changes

YES | NO

Description

A few sentences describing the overall goals of the pull request's commits.

Related PRs

List related PRs against other branches:

branch PR
other_pr_production [link]()
other_pr_master [link]()

Todos

Steps to Test or Reproduce

Outline the steps to test or reproduce the PR here.

Impact to Remaining Code Base

This PR will affect:

felangel commented 2 years ago

List<Object?> is only necessary if one or more props are nullable. Closing for now since the README is accurate as is.

noamraph commented 2 years ago

@felangel First of all I wish to thank you - using Equatable in my code really helped me!

I can say that my experience wasn't smooth - since I have nullable fields, it didn't compile, and I had to dig a bit to find out that the actual overridden property uses List<Object?> so it should be OK to change the type.

If it doesn't affect performance, I still think it would help some users if the examples used Object?. If it does (or if you don't want to measure it), perhaps add a short note about it?

Anyway, again, thanks a lot for your work!

Noam

MrJohn10 commented 1 month ago

Would be helpful if the example mentioned different override to use when you have nullable types.