Ejemplo
equatable 2.1.0: Verify that Equatable does not automatically stringify properties in toString() unless explicitly enabled
Muestra verificada para pub equatable 2.1.0: Verify that Equatable does not automatically stringify properties in toString() unless explicitly enabled. El…
sha256:bec4ea595f73e58cfacf6eb4297d3478d35d6f1994148f087b6ebcf9904d4aec
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 2
- Claves de firma que lo compilaron
- 2
Entorno declarado
dart linux x64 dart dart pub
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| 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 |
Caso
HOW- Objetivo
- Verify that Equatable does not automatically stringify properties in toString() unless explicitly enabled
- Paquetes
- Símbolos
-
- Equatable
- stringify
- Entorno
- dart
- Creado
- 2026-08-17T02:07:29Z
Contrato
- if (User('alice').toString() != 'User') throw 'toString defaults to just the class name, not the formatted props';
Archivos
- NOTES.md
- csx.json
- pubspec.lock
- pubspec.yaml
- test/contract.dart
- test_stringify.dart
Código fuente
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()}');
}