CodeSampleX

샘플

equatable 2.1.0: Give a Dart class value equality with no code generation, so two instances with the same fields are ==, hash the same, and work as Set members and Map keys

검증된 샘플 — pub equatable 2.1.0: Give a Dart class value equality with no code generation, so two instances with the same fields are ==, hash the same, and work…

sha256:89d2bef982143e36175a1174a40d2ddf617e91bf571cde4cd217db418fbf1a1b

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
1
빌드한 서명 키
1
선언된 환경 dart 3 linux x64 dart 3 dart pub

검증 실행 환경

환경 컨트랙트 단계 실행일
dart 3 · linux alpine/x64 · docker ed25519:a2ec939a4c60e243 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · pub@1
2026-08-14

케이스

HOW
목표
Give a Dart class value equality with no code generation, so two instances with the same fields are ==, hash the same, and work as Set members and Map keys
패키지
심벌
  • Equatable
  • Equatable.props
  • Equatable.stringify
  • EquatableMixin
  • EquatableConfig
  • EquatableConfig.stringify
  • copyWith
  • hashCode
  • Set.contains
  • Map.containsKey
환경
dart 3
생성일
2026-08-14T20:03:00Z

컨트랙트

  1. assert two instances with equal fields are == where the same class without Equatable compares by identity, that their hashCodes agree, that a difference in either field is a difference, and that const canonicalization is what makes the unhelped class look right sometimes
  2. assert equatable generates no copyWith, so a hand-written one returns an equal-but-not-identical instance and carries untouched fields over, and that the usual null-coalescing body cannot clear a nullable field while a private sentinel default plus identical can
  3. assert a field left out of props is silently dropped from equality: two orders with different line items are ==, hash the same, collapse to one entry in a Set, and overwrite each other as Map keys with no warning anywhere
  4. assert a List in props is compared element-wise and in order while a Set and a Map prop are order-insensitive, that a nested Equatable composes through its own ==, and that two nums in props compare and hash across int and double
  5. assert a rebuilt equal instance is found by Set.contains and as a Map key, but mutating a List prop in place after insertion changes the hashCode, leaves the object unfindable and unremovable inside the Set, and lets the Set accept an equal duplicate
  6. assert copying that Set does not repair it, because a spread literal and Set.of given another Set carry the stale entry across and Map.of does the same for keys, while routing the elements through a plain Iterable or adding them in a loop rehashes and does repair it
  7. assert runtimeType is compared before props, so a subclass inheriting props verbatim is not == to its parent in either direction, and an inherited hand-written copyWith downcasts it into an unequal parent instance
  8. assert toString prints the props under asserts and only the type name when EquatableConfig.stringify is false, and that a per-instance stringify overrides the global setting
  9. assert Equatable is an abstract mixin class in 2.1.0 so it can be mixed into a class that already extends something, while EquatableMixin still works but is deprecated and is not a subtype of Equatable

파일

  • csx.json
  • lib/value.dart
  • pubspec.lock
  • pubspec.yaml
  • test/contract_test.dart

소스 아티팩트 내려받기 (tar.gz)

오리진 시더

anonymous