flutter-add-widget-test

Implements Flutter widget tests using WidgetTester to verify UI rendering and user interactions.

Updated Jul 23, 2025
One-click install
npx skills add https://github.com/derrik-fleming/dotfiles --skill flutter-add-widget-test-derrik-fleming
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: flutter-add-widget-test
Source: https://github.com/derrik-fleming/dotfiles/tree/main/private_dot_agents/skills/flutter-add-widget-test
Command: npx skills add https://github.com/derrik-fleming/dotfiles --skill flutter-add-widget-test-derrik-fleming

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing component-level tests for Flutter widgets requires knowing the correct WidgetTester APIs, pump semantics, and finder patterns, which are easy to misuse and lead to flaky or incomplete tests. ## Core Features & Use Cases - Structured Test Workflow: Provides a nine-step checklist covering test definition, widget building, finding elements, interaction simulation, and state verification. - Interaction Guidance: Explains when to use pump versus pumpAndSettle, plus patterns for tapping, scrolling, dragging, and entering text. - Use Case: When adding a new screen or component to a Flutter app, use this Skill to generate a complete widget test that verifies initial rendering, simulates user input, and asserts the updated UI state. ## Quick Start Write a Flutter widget test for my TodoList widget that verifies adding and dismissing an item.

Frequently Asked Questions about flutter-add-widget-test

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a Flutter widget test with WidgetTester?▼

Use testWidgets with a WidgetTester callback, call pumpWidget to build the widget, locate elements with finders like find.text or find.byType, then assert with expect and matchers such as findsOneWidget. Wrap widgets in MaterialApp when they need theme or directionality.

How to test button taps and text input in Flutter tests?▼

Use tester.tap(finder) to simulate taps and tester.enterText(finder, 'value') for text fields. After the interaction, call tester.pump() to rebuild the tree, then verify the updated state with expect assertions.

What is the difference between pump and pumpAndSettle in Flutter tests?▼

pump triggers a single frame rebuild, suitable for simple state changes like button taps. pumpAndSettle repeatedly pumps frames until no more are scheduled, which is required for animations, transitions, and asynchronous UI updates.

How do I test items in a long Flutter ListView?▼

Use tester.scrollUntilVisible with the item finder, a scroll delta, and the scrollable finder to bring off-screen items into view before interacting with them. This ensures the target widget is rendered before tapping or asserting.

Why does my Flutter widget test fail to find a widget?▼

Common causes include missing MaterialApp or Directionality wrappers, widgets not yet built because pump was not called after an interaction, or items off-screen in scrollable lists. Verify the finder matches the widget tree and pump appropriately.