felangel / equatable

A Dart package that helps to implement value based equality without needing to explicitly override == and hashCode.

Home Page:https://pub.dev/packages/equatable

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

runtimeType usage

creativecreatorormaybenot opened this issue · comments

This is more of a question as I am not sure:

The package extensively uses runtimeType for equality. Is this safe to do?

Concern

See the first comment to the answer here:

RuntimeType is only for debugging purposes and the application code shouldn't depend on it. It can be overridden by classes to return fake values and probably returns unusable values when transpiled to JS – Günter Zöchbauer Mar 11 '16 at 21:33

Type checks

Why do we not use a type parameter for type checking? :)

We're just comparing runtimeTypes in order to ensure the types are identical which should be safe. Type checks aren't sufficient on their own because subclasses will still be considered equal if we only rely on type checks.

Closing for now but happy to continue the discussion if you have additional thoughts.

See also #175