CodeSampleX

샘플

equatable 2.1.0: Verify that Equatable does not automatically stringify properties in toString() unless explicitly enabled

검증된 샘플 — pub equatable 2.1.0: Verify that Equatable does not automatically stringify properties in toString() unless explicitly enabled. dart 3 · linux…

sha256:bec4ea595f73e58cfacf6eb4297d3478d35d6f1994148f087b6ebcf9904d4aec

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

실행 증거

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

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

검증 실행 환경

환경 컨트랙트 단계 실행일
dart 3 · linux debian/x64 · docker ed25519:d91480838ac982c9 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · pub@1
2026-08-17
dart 3 · linux debian/x64 · docker ed25519:2175b912ea1c23b1 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · pub@1
2026-08-18

케이스

HOW
목표
Verify that Equatable does not automatically stringify properties in toString() unless explicitly enabled
패키지
심벌
  • Equatable
  • stringify
환경
dart
생성일
2026-08-17T02:07:29Z

컨트랙트

  1. if (User('alice').toString() != 'User') throw 'toString defaults to just the class name, not the formatted props';

파일

  • NOTES.md
  • csx.json
  • pubspec.lock
  • pubspec.yaml
  • test/contract.dart
  • test_stringify.dart

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

소스

NOTES.md
When overriding `props` in a class extending `Equatable`, it is common to assume that `toString()` will automatically return a formatted string of the object's properties (e.g. `User(alice)`). 

However, by default, `toString()` only returns the class name. To include the properties, one must explicitly override `bool get stringify => true;` or configure `EquatableConfig.stringify = true;` globally.

The `search_known_solution` lookup yielded two different samples for this library: one covering `runtimeType` checks preventing equality for generics, and another covering basic value equality. This sample demonstrates the default `stringify` behavior instead.
csx.json
{"case":{"believed":"A class extending Equatable automatically formats its fields in toString() output by iterating over its overridden props.","caseId":"case:sha256:a17995751f6d968cc8e0b1879e40ef1da8bc04cece9e78ef2c23a1a5742a8c9d","contract":["if (User('alice').toString() != 'User') throw 'toString defaults to just the class name, not the formatted props';"],"goal":"Verify that Equatable does not automatically stringify properties in toString() unless explicitly enabled","kind":"HOW","packages":["pkg:pub/equatable@2.1.0"],"schemaVersion":1,"symbols":["Equatable","stringify"]},"contractCommand":["dart","test/contract.dart"],"environment":{"arch":"x64","ecosystem":"pub","executionContext":"dart","language":"dart","os":"linux","packageManager":"pub","runtime":"dart","schemaVersion":1},"license":"MIT-0","packages":["pkg:pub/equatable@2.1.0"],"schemaVersion":1,"symbols":["Equatable","stringify"],"verifierAdapter":"pub@1"}
pubspec.lock
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
  collection:
    dependency: transitive
    description:
      name: collection
      sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76"
      url: "https://pub.dev"
    source: hosted
    version: "1.19.1"
  equatable:
    dependency: "direct main"
    description:
      name: equatable
      sha256: "3bce007a596ff8b3119c45d68aaef631272537c03d30e5d4534dd24bf4c5eaa2"
      url: "https://pub.dev"
    source: hosted
    version: "2.1.0"
  meta:
    dependency: transitive
    description:
      name: meta
      sha256: "307249ce4ff29d58a18e97f6345f539382eb9c9c29ecda628900f31de0443dd9"
      url: "https://pub.dev"
    source: hosted
    version: "1.19.0"
sdks:
  dart: ">=3.5.0 <4.0.0"
pubspec.yaml
name: sample
environment:
  sdk: '>=3.0.0 <4.0.0'
dependencies:
  equatable: ^2.1.0
test/contract.dart
import 'package:equatable/equatable.dart';

class User extends Equatable {
  final String name;
  const User(this.name);
  
  @override
  List<Object?> get props => [name];
}

void main() {
  if (User('alice').toString() != 'User') throw 'toString defaults to just the class name, not the formatted props';
}
test_stringify.dart
import 'package:equatable/equatable.dart';

class MyClass extends Equatable {
  final String id;
  const MyClass(this.id);
  
  @override
  List<Object?> get props => [id];
}

void main() {
  final obj = MyClass('abc');
  print('stringify is: ${obj.stringify}');
  print('toString returns: ${obj.toString()}');
}

오리진 시더

csx-seed