Beispiel
Handle unprovided multi-options when explicitly setting defaultsTo to null
sha256:6336a9211912d77dc7e7126ddc7997c3e53e58dc13a1da250530ae1dea82f0ba
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Fall
- Ziel
- Handle unprovided multi-options when explicitly setting defaultsTo to null HOW
- Pakete
- args 2.7.0
- Umgebung
- dart
- Erstellt
- 2026-08-17T02:04:08Z
Häufige Annahme
Setting defaultsTo to null in ArgParser.addMultiOption causes the parsed result to be null if the option is left unset, allowing callers to distinguish an absent option from one given with no values.
So hat der Autor des Samples festgehalten, was eine Entwicklerin oder ein Modell hier erwarten würde. Der Vertrag darunter ist das, was tatsächlich lief.
Contract
- if (results['tags'] == null) throw StateError("ArgParser.addMultiOption silently coerces an explicitly provided defaultsTo: null into an empty list [], meaning the parsed value can never be null.");
- if (results['tags'] is! List || (results['tags'] as List).isNotEmpty) throw StateError("Expected an empty list.");
Dateien
- NOTES.md
- csx.json
- pubspec.lock
- pubspec.yaml
- test/contract.dart
Verifiziertes Artefakt herunterladen (tar.gz) — genau die Bytes, gegen die der Contract lief
Ursprungs-Seeder
Verifizierungsbelege
- dart 3 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · pub@1 · 2026-08-16 · ed25519:d91480838ac982c9