uwuclxdy/agenticat / skills/clean-flutter
clean-flutter
VerifiedIdiomatic Flutter and Dart rules: feature-first layout, Riverpod, freezed, go_router, const correctness.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 6.2 KB |
| references/architecture.md | markdown | 3.2 KB |
| references/models-serialization.md | markdown | 2.8 KB |
| references/navigation.md | markdown | 1.9 KB |
| references/packages.md | markdown | 2.9 KB |
| references/pitfalls.md | markdown | 4.4 KB |
| references/state-management.md | markdown | 3.9 KB |
| references/testing.md | markdown | 3.2 KB |
references/testing.md
View on GitHub# Testing
The test pyramid for Flutter: what each layer asserts, and the tooling for it.
| Layer | Tool | Asserts | Volume |
|---|---|---|---|
| unit | `test` / `flutter_test` | pure logic: view models, repositories (with faked data sources), `Result` mapping, domain rules | most tests |
| widget | `testWidgets` + `WidgetTester` | one widget's behavior: renders expected content, taps and scrolls drive state, conditional UI shows/hides | many |
| golden | `alchemist` | pixel snapshot of a widget across themes and sizes | targeted |
| integration | `integration_test` package | full app flows on a device or emulator | few |
## What Each Layer Asserts
- **Widget tests assert behavior and rendered output, not internals.** Pump the widget, find by text/key/type, tap, and assert the visible result. Don't pin a private method's call count.
- **Mock at the repository or data-source boundary** (`mocktail`), not the widgets under test. Inject the fake by overriding its provider in `ProviderScope(overrides: [...])`.
- **Riverpod in tests:** drive a notifier through its provider (`container.read(provider.notifier)`), never by constructing it. Use a `ProviderContainer` (with `addTearDown(container.dispose)`) for provider-only unit tests; use `ProviderScope` overrides for widget tests.
## Golden Tests
- `alchemist` is the current standard; `golden_toolkit` is discontinued.
- Alchemist splits **CI goldens** (text rendered as colored blocks, which dodges cross-platform font-rendering flake) from **platform goldens** (human-readable text for local review). Run CI goldens in the pipeline so a font-metric difference between machines doesn't fail the build.
## Integration Tests
Use the bundled `integration_test` package driving real flows, not the legacy `flutter drive` harness. Keep these few and reserved for critical end-to-end paths; they're the slowest and flakiest tier.
## Discipline
- A test that can't fail is a bug in the test. Assert exact expected values and the error and loading branches (`AsyncValue` carries all three), then watch it fail once against the code before the change (never by breaking the assertion) before trusting green.
- Reproduce a reported bug with a failing widget or unit test *before* fixing it.
- `pump` advances a single frame; `pumpAndSettle` runs frames until animations finish. Use `pump(duration)` for timers you control; `pumpAndSettle` hangs on an indefinite animation (a spinner), so pump explicit durations there instead.
- a test that an API throws synchronously: `expect(() { unawaited(f()); }, throwsX)`. `expectLater(() => f(), throwsX)` waits on the returned `Future`, so an `f` that opens a route instead of throwing hangs the test rather than failing it.
- A reduced-motion test that sets `MediaQuery(disableAnimations: true)` alone never reaches the framework's own cut: under the OS flag (Android "remove animations", web `prefers-reduced-motion`) a `normal` `AnimationController`'s `forward` / `reverse` / `animateTo` / `animateBack` run at 5% (`repeat`, `animateWith` and `preserve` controllers run whole). Also set `tester.platformDispatcher.accessibilityFeaturesTestValue = const FakeAccessibilityFeatures(disableAnimations: true)`, cleared in tear-down (measured 2026-10-23, Flutter 3.47.0).
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |