Ack validates data in Dart and Flutter. This branch documents 2.0.0-beta.3; see the migration guide for 1.x changes.
- Schemas define accepted boundary data and the Dart values it becomes.
- Parsing validates input;
safeParsereturns a result. Codecs also encode runtime values back to the boundary. - Presence and null differ:
optionalpermits omission,nullablepermits null, andJsonMaybepreserves both states. - Generation is optional:
@Schemableturns schemas into models or hand-written classes into schemas, using one.g.dartpart. - Generated model constructors are unchecked; use parsing for untrusted input and JSON encoding for validated output.
- Native schemas export Draft-7; imported 2020-12 resources retain their dialect unless explicitly lowered.
- Adapters reuse schemas for Firebase AI, MCP inputs, and
json_schema_builder; Ack still validates the data.
Install the version documented on this branch:
dart pub add ack:^2.0.0-beta.3import 'package:ack/ack.dart';
final userSchema = Ack.object({
'name': Ack.string().minLength(2),
'nickname': Ack.string().optional().nullable(),
});
final result = userSchema.safeParse({'name': 'Ada'});
if (result.isOk) {
print(result.getOrThrow());
} else {
print(result.getError());
}See installation for SDK requirements,
model generation for @Schemable, and
codecs for encoding and callback failure semantics.
| Package | Purpose |
|---|---|
| ack | Runtime schemas, codecs, JSON Schema import/export, annotations |
| ack_generator | Models from schemas and schemas from classes |
| ack_firebase_ai | Firebase AI response JSON Schema maps |
| ack_json_schema_builder | Bidirectional json_schema_builder bridge |
| ack_mcp_dart | MCP input schemas and typed argument validation |
Examples demonstrate the packages together.
- Guides and the branch-local agent API index
- Architecture decisions: rationale and superseded choices
- CONTRIBUTING.md: setup, checks, and generator resource limits
- PUBLISHING.md: coordinated releases and tag-only publication
- SUPPORT.md, SECURITY.md, and Code of Conduct