/flutter-ai-skills:mocktailfrom Flutter AI Skills
Provides guidelines for using the mocktail package in Dart/Flutter tests: creating mocks, stubbing, verifying interactions, registering fallback values, and choosing between mocks, fakes, and real objects.
Ships in Flutter AI Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
This skill defines how to correctly use the mocktail package for mocking in Dart and Flutter tests.
| Use | When |
|---|---|
| Real object | Prefer over mocks when practical. |
Fake (extends Fake) | Lightweight custom implementation; override only the methods you need. Prefer over mocks when you don't need interaction verification. |
Mock (extends Mock) | Only when you need to verify interactions (call counts, arguments) or stub dynamic responses. |
@override methods or implementations to a class extending Mock.verify assertions; otherwise prefer real or fake objects.class MockMyService extends Mock implements MyService {}
class FakeMyEvent extends Fake implements MyEvent {}
No code generation required — unlike Mockito, Mocktail uses noSuchMethod at runtime.
Register fallback values before using custom types with argument matchers. Do this in setUpAll or at the top of your test:
setUpAll(() {
registerFallbackValue(FakeMyEvent());
});
any(), captureAny(), or captureThat().final mock = MockMyService();
// Return a value
when(() => mock.fetchData()).thenReturn('result');
// Throw an error
when(() => mock.fetchData()).thenThrow(Exception('error'));
// Dynamic/async response
when(() => mock.fetchData()).thenAnswer((_) async => 'result');
// Future<void>
when(() => mock.doWork()).thenAnswer((_) async {});
Future or Future<void>) with thenAnswer.Always include all named parameters in both when and verify calls. Use any(named: 'paramName') for those you don't care about:
when(() => mock.fetch(
id: any(named: 'id'),
headers: any(named: 'headers'),
)).thenReturn(response);
verify(() => mock.fetchData()); // called at least once
verifyNever(() => mock.fetchData()); // never called
verify(() => mock.fetchData()).called(2); // called exactly twice
// Any positional argument
when(() => mock.process(any())).thenReturn(true);
// Capture arguments for later assertions
final captured = verify(() => mock.process(captureAny())).captured;
print(captured.last);
any() for positional parameters when you don't care about the exact value.captureThat() for conditional capturing..toString() returns for the type.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub evanca/flutter-ai-rules --plugin flutter-ai-skills36 skills in this plugin
/accessibilityUse when working on accessibility, a11y, WCAG, ARIA, screen readers, keyboard nav, focus order, contrast, alt text, captions, reduced motion, or target sizes; not language/culture/device (see inclusive-design)./architecture-feature-firstUse when creating a feature, designing folder structure, adding repositories/services/view models, wiring dependency injection, or deciding which layer owns logic./blocUse when creating a Cubit or Bloc, modeling state with sealed classes or status enums, wiring BlocBuilder/BlocListener/BlocProvider, writing bloc tests, or choosing between Cubit and Bloc./code-reviewUse when asked to review a PR, MR, branch, or diff, audit changed files, or check code quality./dart-3-updatesUse when writing switch statements, refactoring if-else chains, creating data classes, choosing records vs classes, destructuring values, or modernizing pre-Dart-3 code./developing-genkit-dartUse when building AI agents in Dart, implementing Genkit flows or tools, integrating LLMs into Dart or Flutter applications, or using Genkit Dart plugins.Other plugins' skills for the same job