
Flutter Add Widget Test
Use this when you want a component-level test for a single Flutter widget, checking that it renders the right data and responds to taps, text entry, or scrolling without spinning up a full integration run. It walks through the standard `testWidgets` flow: pump the widget, locate elements with `Finder`s, assert with `Matcher`s, simulate interactions, then call `pump` or `pumpAndSettle` depending on whether you're waiting on a single rebuild or an animation. The example is a todo list with add and swipe-to-dismiss, which covers the `enterText`, `tap`, and `drag` paths well. One honest caveat: the sample wraps the widget in a `MaterialApp` inside `build`, which is a pattern worth questioning in your own code since it nests navigation and theming in the widget under test. The checklist and conditional guidance on when to use `pump` versus `pumpAndSettle` are the most reusable parts.
- skills.sh installs
- 41.4K
- GitHub stars
- 3.2K
- last updated
- Oct 26, 2026
Install
$ npx -y skills add flutter/agent-plugins --skill flutter-add-widget-test --agent claude-codeInstalls into .claude/skills of the current project.
Files
Writing Flutter Widget Tests
Contents
- Setup & Configuration
- Core Components
- Workflow: Implementing a Widget Test
- Interaction & State Management
- Examples
Setup & Configuration
Ensure the testing environment is properly configured before authoring widget tests.
- Add the
flutter_testdependency to thedev_dependenciessection ofpubspec.yaml. - Place all test files in the
test/directory at the root of the project. - 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:
Sponsors
Details
- Repository
- github.com/flutter/agent-plugins
- Categories
- Frontend Development, Testing & QA, AI & Agent Building, Mobile Development
- First seen
- Oct 26, 2026
More from flutter/agent-plugins
All 10- Flutter Add Integration Test40.2K
- Flutter Setup Declarative Routing39.7K
- Flutter Implement Json Serialization39.4K
- Flutter Add Widget Preview38.7K
- Flutter Setup Localization38.7K
- Flutter Use Http Package37.9K
- Flutter Apply Architecture Best Practices45.5K
- Flutter Build Responsive Layout45.1K
- Flutter Fix Layout Issues42.2K