Beispiel
equatable 2.1.0: Verify that Equatable does not automatically stringify properties in toString() unless explicitly enabled
Verifiziertes Beispiel für pub equatable 2.1.0: Verify that Equatable does not automatically stringify properties in toString() unless explicitly enabled.…
sha256:bec4ea595f73e58cfacf6eb4297d3478d35d6f1994148f087b6ebcf9904d4aec
Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen.
Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen.
MIT-0
Ausführungsbelege
Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.
- Beleggrundlage
- Signierter Vertrag bestanden
- Verifizierungsbelege
- 2
- Signaturschlüssel, die es gebaut haben
- 2
Deklarierte Umgebung
dart linux x64 dart dart pub
Umgebungen der Verifizierungsläufe
| Umgebung | Contract | Stufen | Lauf |
|---|---|---|---|
| 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 |
Fall
HOW- Ziel
- Verify that Equatable does not automatically stringify properties in toString() unless explicitly enabled
- Pakete
- Symbole
-
- Equatable
- stringify
- Umgebung
- dart
- Erstellt
- 2026-08-17T02:07:29Z
Contract
- if (User('alice').toString() != 'User') throw 'toString defaults to just the class name, not the formatted props';
Dateien
- NOTES.md
- csx.json
- pubspec.lock
- pubspec.yaml
- test/contract.dart
- test_stringify.dart
Quelltext
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.
{"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"}
# 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"
name: sample
environment:
sdk: '>=3.0.0 <4.0.0'
dependencies:
equatable: ^2.1.0
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';
}
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()}');
}