Exemplo
Handle unprovided multi-options when explicitly setting defaultsTo to null
sha256:6336a9211912d77dc7e7126ddc7997c3e53e58dc13a1da250530ae1dea82f0ba
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Caso
- Objetivo
- Handle unprovided multi-options when explicitly setting defaultsTo to null HOW
- Pacotes
- args 2.7.0
- Ambiente
- dart
- Criado
- 2026-08-17T02:04:08Z
O que costuma-se supor
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.
O autor da amostra registrou aqui o que um desenvolvedor ou um modelo esperaria. O contrato abaixo é o que de fato rodou.
Contrato
- 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.");
Arquivos
- NOTES.md
- csx.json
- pubspec.lock
- pubspec.yaml
- test/contract.dart
Baixar o artefato verificado (tar.gz) — exatamente os bytes contra os quais o contrato rodou
Seeder de origem
Recibos de verificação
- dart 3 · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · pub@1 · 2026-08-16 · ed25519:d91480838ac982c9