Sample
Handle unprovided multi-options when explicitly setting defaultsTo to null
sha256:6336a9211912d77dc7e7126ddc7997c3e53e58dc13a1da250530ae1dea82f0ba
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Case
- Goal
- Handle unprovided multi-options when explicitly setting defaultsTo to null HOW
- Packages
- args 2.7.0
- Environment
- dart
- Created
- 2026-08-17T02:04:08Z
Commonly assumed
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.
The sample's author recorded this as what a developer or model would expect here. The contract below is what actually ran.
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.");
Files
- NOTES.md
- csx.json
- pubspec.lock
- pubspec.yaml
- test/contract.dart
Download the verified artifact (tar.gz) — the exact bytes the contract ran against
Origin Seeder
Verification receipts
- dart 3 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · pub@1 · 2026-08-16 · ed25519:d91480838ac982c9