Skip to Content
DocsAckGetting StartedOverview

Overview

External data can’t be trusted. APIs change, users mistype, and JSON drifts from what your code expects. Ack is a schema validation library for Dart and Flutter that puts a guardrail at those boundaries: describe the shape you expect once, then check untrusted data against it. You get a clear error when it doesn’t match — and your data, validated, when it does.

(“Ack” is short for “acknowledgment.”)

import 'package:ack/ack.dart'; final userSchema = Ack.object({ 'name': Ack.string().minLength(2).maxLength(50), 'age': Ack.integer().min(0).max(120), 'email': Ack.string().email().nullable(), }); final result = userSchema.safeParse({ 'name': 'Ada', 'age': 36, 'email': 'ada@example.com', }); if (result.isOk) { print('Welcome, ${result.getOrThrow()!['name']}'); } else { print(result.getError()); // tells you exactly which field failed, and why }

On success, getOrThrow() returns your validated data as a Map<String, Object?>. Ack checks and shapes the data — opt into model code generation when you’d rather have typed getters than map access or want a schema generated from an existing class.

Why Ack?

  • Guard your boundaries. Catch bad API responses, user input, and config before they reach your logic.
  • Define each shape once. Reuse one schema for validation, JSON Schema export, and typed models.
  • Errors you can act on. Every failure points at the exact field and the reason it failed.
  • Just Dart. A fluent API with no required build step — reach for code generation only when you want it.

What do you want to do?

Install

dart pub add ack:^2.0.0-beta.3

New here? The Quickstart Tutorial takes you from install to handling every validation outcome in a few minutes.

Learn more

Building with an AI agent? Start at llms.txt for a compact, machine-readable index.

Last updated on