flutter-add-widget-test

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

Updated Jan 8, 2026
One-click install
npx skills add https://github.com/arslan9024/White-Caves --skill flutter-add-widget-test-arslan9024
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: flutter-add-widget-test
Source: https://github.com/arslan9024/White-Caves/tree/main/.agents/skills/flutter-add-widget-test
Command: npx skills add https://github.com/arslan9024/White-Caves --skill flutter-add-widget-test-arslan9024

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing component-level tests for Flutter UIs requires knowing the correct WidgetTester APIs, pump semantics, and Finder/Matcher patterns, which are easy to misuse and produce flaky or incomplete tests. ## Core Features & Use Cases - Structured Test Workflow: Provides a step-by-step checklist covering test definition, widget building, element location, interaction simulation, and state verification. - Interaction Handling Guidance: Explains when to use pump versus pumpAndSettle for taps, animations, text entry, and scrolling in long lists. - Use Case: When adding a new feature like a todo list with add and dismiss behavior, use this Skill to generate a complete widget test that enters text, taps the add button, swipes to dismiss, and asserts the UI updates correctly. ## Quick Start Write a Flutter widget test for my TodoList widget that verifies adding an item via the floating action button and removing it with a dismiss swipe.

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 widget test in Flutter?▼

Use the testWidgets function with a WidgetTester callback, call tester.pumpWidget to render your widget, then use Finder objects with expect and Matchers like findsOneWidget to verify the UI. Wrap widgets in MaterialApp when they need theme or directionality context.

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

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

How do I test scrolling in a Flutter ListView?▼

Use tester.scrollUntilVisible with the target item finder, a scroll delta, and the scrollable finder to bring off-screen items into view before interacting with them. This ensures dynamically built list items are rendered before assertions.

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

Common causes include missing pump calls after state changes, widgets not yet built in lazy lists, or absent MaterialApp or Directionality ancestors. Verify the Finder matches the widget tree and pump frames after each interaction.

Where should Flutter test files be placed?▼

Place all test files in the test directory at the project root and suffix file names with _test.dart. Add flutter_test to the dev_dependencies section of pubspec.yaml before running flutter test.