No slash command · from flutter-plugin
Tests Flutter apps with unit, widget, golden, and integration tests. Covers Riverpod overrides, bloc_test, mocktail, pumpApp helper, accessibility checks, and coverage.
Ships in flutter-plugin. 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.
| Layer | Tool | Location | Runs in pipeline |
|---|---|---|---|
| Unit — repositories, mappers, notifiers, blocs | flutter_test / test, mocktail, bloc_test | test/ | yes |
| Widget — one screen or component | testWidgets | test/ | yes |
| Golden — pixel snapshot | matchesGoldenFile (or alchemist if installed) | test/ | yes, only if the project already has goldens |
| Integration — whole app on a device | integration_test (or patrol if installed) | integration_test/ | no — needs a device/emulator |
Mirror lib/ paths: lib/features/orders/presentation/orders_screen.dart → test/features/orders/presentation/orders_screen_test.dart.
Widgets need the real app scaffolding (theme, localization delegates, providers, sometimes a router). Reuse the project's helper (test/helpers/pump_app.dart) if it exists; otherwise add one:
extension PumpApp on WidgetTester {
Future<void> pumpApp(Widget widget, {List<Override> overrides = const []}) {
return pumpWidget(
ProviderScope( // or MultiRepositoryProvider / MultiBlocProvider
overrides: overrides,
child: MaterialApp(
theme: AppTheme.light,
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: widget,
),
),
);
}
}
class _MockOrderRepository extends Mock implements OrderRepository {}
void main() {
late _MockOrderRepository repository;
setUp(() => repository = _MockOrderRepository());
testWidgets('shows orders after loading', (tester) async {
when(() => repository.fetchOrders()).thenAnswer((_) async => [Order(id: '1', total: 10)]);
await tester.pumpApp(
const OrdersScreen(),
overrides: [orderRepositoryProvider.overrideWithValue(repository)],
);
expect(find.byType(CircularProgressIndicator), findsOneWidget);
await tester.pump(); // let the future complete
expect(find.byType(OrderTile), findsOneWidget);
});
testWidgets('shows retry on failure', (tester) async {
when(() => repository.fetchOrders()).thenThrow(NetworkException());
await tester.pumpApp(const OrdersScreen(), overrides: [orderRepositoryProvider.overrideWithValue(repository)]);
await tester.pump();
await tester.tap(find.widgetWithText(FilledButton, 'Retry'));
await tester.pump();
verify(() => repository.fetchOrders()).called(2);
});
}
find.byType, find.text / find.widgetWithText, find.bySemanticsLabel, find.byKey. Use keys when text is localized or ambiguous.pump() advances one frame (resolves completed futures); pump(duration) advances time; pumpAndSettle() waits for animations to finish — it times out on infinite animations (spinners), so do not use it while a CircularProgressIndicator is visible.tap, enterText, drag, scrollUntilVisible; always pump after.Future.delayed/timers — inject durations or use tester.pump(duration).mocktail_image_network (if installed); real HTTP fails in tests.test('cart adds items', () {
final container = ProviderContainer(overrides: [/* fakes */]);
addTearDown(container.dispose);
container.read(cartProvider.notifier).add(item);
expect(container.read(cartProvider), [item]);
});
ProviderContainer.test(), which disposes automatically — use it when available.AsyncLoading instead of AsyncError. Disable it in tests: ProviderContainer.test(retry: (_, __) => null) / ProviderScope(retry: (_, __) => null, …) in the pumpApp helper.await container.read(ordersProvider.future).container.listen(provider, listener.call, fireImmediately: true) and a mocktail Listener to assert loading → data.blocTest<OrdersBloc, OrdersState>(
'emits [loading, loaded] when orders are requested',
build: () {
when(() => repository.fetchOrders()).thenAnswer((_) async => orders);
return OrdersBloc(repository);
},
act: (bloc) => bloc.add(const OrdersRequested()),
expect: () => [const OrdersLoading(), OrdersLoaded(orders)],
);
Widget tests for bloc-driven screens: provide a MockBloc (class _MockOrdersBloc extends MockBloc<OrdersEvent, OrdersState> implements OrdersBloc {}) and whenListen / when(() => bloc.state) to set state directly.
MaterialApp.router(routerConfig: GoRouter(initialLocation: '/orders/1', routes: appRoutes)) to test a deep route; assert on find.byType(OrderDetailsScreen).GoRouter via InheritedGoRouter or test the resulting screen — follow the project's existing pattern.For new screens:
final handle = tester.ensureSemantics();
await tester.pumpApp(const CheckoutScreen());
await expectLater(tester, meetsGuideline(androidTapTargetGuideline));
await expectLater(tester, meetsGuideline(iOSTapTargetGuideline));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
Only when the project already has golden tests:
await expectLater(find.byType(OrderCard), matchesGoldenFile('goldens/order_card.png'));flutter_test_config.dart or loadAppFonts() from its helper) or goldens render with the test font.flutter test --update-goldens <file> and state in the report that goldens were updated — rendering differs across OSes, so CI may need to regenerate them on its platform.Only if integration_test/ exists. Write the flow (IntegrationTestWidgetsFlutterBinding.ensureInitialized(), then testWidgets driving the real app) but do not run it — it needs a device. List it in the report as "written, not executed".
flutter test # all unit + widget tests
flutter test test/features/orders # one feature
flutter test --coverage # coverage/lcov.info
Prefix with fvm when the project pins its SDK with FVM.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub aratkruglik/claude-sdlc --plugin flutter-plugin4 skills in this plugin
/flutter-conventionsFlutter project structure and widget conventions: app vs package detection, feature-first vs layer-first layout, widget composition and const discipline, StatelessWidget vs StatefulWidget lifecycle, BuildContext rules, keys, theming with ThemeData/ColorScheme/ThemeExtension, responsive and adaptive layout, accessibility (Semantics, text scaling, tap targets), localization with gen-l10n, assets and fonts, flavors, platform channels, secure storage, performance.
Use this skill to:
- Build screens from small, const, testable widgets.
- Manage widget lifecycle (controllers, subscriptions, animations) without leaks.
- Read styling from the theme and keep screens responsive and accessible.
- Add strings, assets, permissions and platform code the way the project already does.
Do NOT use this skill for:
- State management choice and patterns (see flutter-state-management).
- Routing and deep links (see flutter-navigation).
- Testing (see flutter-testing).
- Plain Dart idioms (see dart-foundation:dart-conventions).
/flutter-navigationNavigation in Flutter apps: detecting go_router / auto_route / Navigator, adding routes and nested navigation (ShellRoute / StatefulShellRoute for tab bars), typed routes with go_router_builder, path and query parameters, auth redirects and guards, deep links / Android App Links / iOS Universal Links, passing data between screens, returning results, web URL strategy.
Use this skill to:
- Register a new screen in the router the project already uses.
- Pass parameters safely and validate deep-link input.
- Protect routes behind authentication with redirects.
- Keep tab state with stateful shell routes.
Do NOT use this skill for:
- Widget structure (see flutter-conventions).
- State that drives navigation decisions (see flutter-state-management).
- Testing routes (see flutter-testing).
/flutter-state-managementState management in Flutter apps: detecting the installed approach and following it — Riverpod 2/3 (Notifier/AsyncNotifier, code-gen @riverpod, ref.watch/read/listen, overrides), Bloc/Cubit (events, sealed states, BlocBuilder/BlocListener/BlocSelector, hydrated_bloc), Provider (ChangeNotifier), and plain ValueNotifier/ChangeNotifier. Modelling loading/empty/error/data states, repository boundaries, side effects, dependency injection.
Use this skill to:
- Pick the right primitive inside the library the project already uses.
- Model async screen state so loading, error and empty are never forgotten.
- Keep business logic out of widgets and testable without Flutter.
- Trigger one-off effects (snackbars, navigation) without rebuild bugs.
Do NOT use this skill for:
- Ephemeral widget state like text controllers (see flutter-conventions — StatefulWidget).
- Navigation (see flutter-navigation).
- Testing notifiers and blocs (see flutter-testing).
Other plugins' skills for the same job