flutter-add-widget-test
Implement a component-level test using `WidgetTester` to verify UI rendering and user interactions (tapping, scrolling, entering text).
Skill by maranix
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/maranix-flutter-add-widget-test
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: design, frontend, testing, data
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/flutter-add-widget-test
What's inside
- Skill name
flutter-add-widget-test- Description
- Implement a component-level test using `WidgetTester` to verify UI rendering and user interactions (tapping, scrolling, entering text). Use when validating that a specific widget displays correct data and responds to events as expected.
- License
- MIT
- Metadata
- model: models/gemini-3.1-pro-preview · last_modified: Tue, 21 Apr 2026 21:15:41 GMT
- Instructions
- 148 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Writing Flutter Widget Tests
## Contents
- [Setup & Configuration](#setup--configuration)
- [Core Components](#core-components)
- [Workflow: Implementing a Widget Test](#workflow-implementing-a-widget-test)
- [Interaction & State Management](#interaction--state-management)
- [Examples](#examples)
## Setup & Configuration
Ensure the testing environment is properly configured before authoring widget tests.
1. Add the `flutter_test` dependency to the `dev_dependencies` section of `pubspec.yaml`.
2. Place all test files in the `test/` directory at the root of the project.
3. Suffix all test file names with `_test.dart` (e.g., `widget_test.dart`).
## Core Components
Utilize the following `flutter_test` components to interact with and validate the widget tree:
* **`WidgetTester`**: The primary interface for building and interacting with widgets in the test environment. Provided automatically by the `testWidgets()` function.
* **`Finder`**: Locates widgets in the test environment (e.g., `find.text('Submit')`, `find.byType(TextField)`, `find.byKey(Key('submit_btn'))`).
* **`Matcher`**: Verifies the presence or state of widgets located by a `Finder` (e.g., `findsOneWidget`, `findsNothing`, `findsNWidgets(2)`, `matchesGoldenFile`).
## Workflow: Implementing a Widget Test
Copy the following checklist to track progress when implementing a new widget test.
### Task Progress
- [ ] **Step 1: Define the test.** Use `testWidgets('description', (WidgetTester tester) async { ... })`.
- [ ] **Step 2: Build the widget.** Call `await tester.pumpWidget(MyWidget())` to render the UI. Wrap the widget in a `MaterialApp` or `Directionality` widget if it requires inherited directional or theme data.
- [ ] **Step 3: Locate elements.** Instantiate `Finder` objects for the target widgets.
- [ ] **Step 4: Verify initial state.** Use `expect(finder, matcher)` to validate the initial render.
- [ ] **Step 5: Simulate interactions.** Execute gestures or inputs (e.g., `await tester.tap(buttonFinder)`).
- [ ] **Step 6: Rebuild the tree.** Call `await tester.pump()` or `await tester.pumpAndSettle()` to process state changes.
- [ ] **Step 7: Verify updated state.** Use `expect()` to validate the UI after the interaction.
- [ ] **Step 8: Run and validate.** Execute `flutter test test/your_test_file_test.dart`.
- [ ] **Step 9: Feedback Loop.** Review test output -> identify failing matchers -> adjust widget logic or test assertions -> re-run until passing.
## Interaction & State Management
Apply the following conditional logic based on the type of interaction or state change being tested:
* **If testing static rendering:** Call `await tester.pumpWidget()` once, then immediately run `expect()` assertions.
* **If testing standard state changes (e.g., button taps):**
1. Call `await tester.tap(finder)`.
2. Call `await tester.pump()` to trigger a single frame rebuild.
* **If testing animations, transitions, or asynchronous UI updates:**
1. Trigger the action (e.g., `await tester.drag(finder, Offset(500, 0))`).
2. Call `await tester.pumpAndSettle()` to repeatedly pump frames until no more frames are scheduled (animation completes).
* **If testing text input:** Call `await tester.enterText(textFieldFinder, 'Input string')`.
* **If testing items in a dynamic or long list:** Call `await tester.scrollUntilVisible(itemFinder, 500.0, scrollable: listFinder)` to ensure the target widget is rendered before interacting with it.
## Examples
### High-Fidelity Widget Test Implementation
**Target Widget (`lib/todo_list.dart`):**
```dart
import 'package:flutter/material.dart';
class TodoList extends StatefulWidget {
const TodoList({super.key});
@override
State<TodoList> createState() => _TodoListState();
}
class _TodoListState extends State<TodoList> {
final todos = <String>[];
final controller = TextEditingController();
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Column(
children: [
TextField(controller: controller),
Expanded(
child: ListView.builder(
itemCount: todos.length,
itemBuilder: (context, index) {
final todo = todos[index];
return Dismissible(
key: Key('$todo$index'),
onDismissed: (_) => setState(() => todos.removeAt(index)),
child: ListTile(title: Text(todo)),
);
},
),
),
],
),
floatingActionButton: FloatingActionButton(
onPressed: () {
setState(() {
todos.add(controller.text);
controller.clear();
});
},
child: const Icon(Icons.add),
),
),
);
}
}
```
**Test Implementation (`test/todo_list_test.dart`):**
```dart
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:my_app/todo_list.dart';
void main() {
testWidgets('Add and remove a todo item', (WidgetTester tester) async {
// 1. Build the widget
await tester.pumpWidget(const TodoList());From maranix/skills, MIT.
More from maranix/skills
- 0.524score
dart-add-unit-test
maranix
Write and organize unit tests for functions, methods, and classes using `package:test`.
SkillBFreshness: BClaude Code +9 - 0.524score
dart-generate-test-mocks
maranix
Define and generate mock objects for external dependencies using `package:mockito` and `build_runner`.
SkillBFreshness: BClaude Code +9 - 0.524score
dart-build-cli-app
maranix
Entrypoint structure, exit codes, cross-platform scripts.
SkillBFreshness: BClaude Code +9 - 0.524score
flutter-add-integration-test
maranix
Configures Flutter Driver for app interaction and converts MCP actions into permanent integration tests.
SkillBFreshness: BClaude Code +9 - 0.524score
dart-setup-ffi-assets
maranix
Guides agents in compiling and packaging C/C++ source code into dynamic or static libraries (Code Assets) using Dart's Native Assets hook system (via…
SkillBFreshness: BClaude Code +9 - 0.524score
dart-use-ffigen
maranix
Guide agents to use `package:ffigen` to automatically generate FFI bindings instead of writing them manually.
SkillBFreshness: BClaude Code +9 - 0.524score
flutter-apply-architecture-best-practices
maranix
Architects a Flutter application using the recommended layered approach (UI, Logic, Data).
SkillBFreshness: BClaude Code +9 - 0.524score
flutter-build-responsive-layout
maranix
Use `LayoutBuilder`, `MediaQuery`, or `Expanded/Flexible` to create a layout that adapts to different screen sizes.
SkillBFreshness: BClaude Code +9 - 0.523score
dart-resolve-package-conflicts
maranix
Workflow for fixing package version conflicts.
SkillBFreshness: BClaude Code +9 - 0.521score
dart-fix-runtime-errors
maranix
Uses get_runtime_errors and lsp to fetch an active stack trace, locate the failing line, apply a fix, and verify resolution via hot_reload.
SkillBFreshness: BClaude Code +9 - 0.521score
dart-run-static-analysis
maranix
Execute `dart analyze` to identify warnings and errors, and use `dart fix --apply` to automatically resolve mechanical lint issues.
SkillBFreshness: BClaude Code +9 - 0.521score
dart-use-primary-constructors
maranix
Help users write syntactically and semantically correct primary constructors in Dart, and migrate/use the new constructor syntax, empty-body semicolon syntax…
SkillBFreshness: BClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Aug 13, 2026 (2 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/maranix/skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from maranix
- 0.524score
dart-add-unit-test
maranix
Write and organize unit tests for functions, methods, and classes using `package:test`.
SkillBFreshness: BClaude Code +9 - 0.524score
dart-setup-ffi-assets
maranix
Guides agents in compiling and packaging C/C++ source code into dynamic or static libraries (Code Assets) using Dart's Native Assets hook system (via…
SkillBFreshness: BClaude Code +9 - 0.524score
flutter-add-integration-test
maranix
Configures Flutter Driver for app interaction and converts MCP actions into permanent integration tests.
SkillBFreshness: BClaude Code +9 - 0.524score
dart-generate-test-mocks
maranix
Define and generate mock objects for external dependencies using `package:mockito` and `build_runner`.
SkillBFreshness: BClaude Code +9 - 0.524score
dart-build-cli-app
maranix
Entrypoint structure, exit codes, cross-platform scripts.
SkillBFreshness: BClaude Code +9 - 0.524score
dart-use-ffigen
maranix
Guide agents to use `package:ffigen` to automatically generate FFI bindings instead of writing them manually.
SkillBFreshness: BClaude Code +9
Cite this page
flutter-add-widget-test skill. Agent Mart. https://agentmart.dev/skills/maranix-flutter-add-widget-test (last updated 2026-10-24)