flutter avatar

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-code

Installs into .claude/skills of the current project.

Files

Writing Flutter Widget Tests

Contents

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:

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
1clerk avatarclerk-react-patternsclerk/skillsReact SPA auth patterns with @clerk/react for Vite/CRA - ClerkProvider setup, useAuth/useUser/useClerk hooks, React Router protected routes, custom sign-in flow20.4Kskills.sh installs
2antfu avatarvue-router-best-practicesantfu/skillsVue Router 4 patterns, navigation guards, route params, and route-component lifecycle interactions.18.8Kskills.sh installs
3lombiq avatartailwind-4-docslombiq/tailwind-agent-skillsComprehensive Tailwind CSS v4 documentation snapshot and workflow guidance. Use when answering Tailwind v4 questions, selecting utilities/variants, configuring 18.6Kskills.sh installs
4antfu avatarvue-testing-best-practicesantfu/skillsUse for Vue.js testing. Covers Vitest, Vue Test Utils, component testing, mocking, testing patterns, and Playwright for E2E testing.17.2Kskills.sh installs
5vuejs-ai avatarvue-router-best-practicesvuejs-ai/skillsVue Router 4 patterns, navigation guards, route params, and route-component lifecycle interactions.16.2Kskills.sh installs
6clerk avatarclerk-vue-patternsclerk/skillsVue 3 patterns with Clerk — composables (useAuth, useUser, useClerk, useOrganization), Vue Router guards, Pinia auth store integration. Triggers on: vue clerk, 14.5Kskills.sh installs