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

このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。 合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。 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