---
title: 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.")

```dart
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 [code generation](/core-concepts/typesafe-schemas) when you'd rather have typed getters than map access.

## 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?

- **Validate an API response** — [Quickstart Tutorial](/getting-started/quickstart-tutorial), then [JSON Serialization](/core-concepts/json-serialization)
- **Show field errors in a Flutter form** — [Flutter Form Validation](/guides/flutter-form-validation)
- **Make a field optional or nullable** — [Optional vs nullable](/core-concepts/schemas#optional-vs-nullable)
- **Parse dates, URIs, and durations** — [Codecs](/core-concepts/codecs)
- **Add custom validation logic** — [Custom Validation](/guides/custom-validation)
- **Generate typed models (no manual casts)** — [TypeSafe Schemas](/core-concepts/typesafe-schemas)
- **Reuse and compose schemas** — [Common Recipes](/guides/common-recipes)

## Install

```bash
dart pub add ack
```

New here? The [Quickstart Tutorial](/getting-started/quickstart-tutorial) takes you from install to handling every validation outcome in a few minutes.

## Learn more

- [Schema Types](/core-concepts/schemas) — every schema type and how to compose them
- [Validation Rules](/core-concepts/validation) — built-in constraints
- [Error Handling](/core-concepts/error-handling) — read and display structured errors
- [JSON Serialization](/core-concepts/json-serialization) — validate and encode JSON
- [API Reference](/api-reference/) — the full surface

*Building with an AI agent? Start at [`/llms.txt`](/llms.txt) for a compact, machine-readable index.*
