flutter-add-widget-test

Write Flutter widget tests using the WidgetTester API to verify UI rendering and interactions.

2.8k|166|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/flutter/agent-plugins --skill flutter-add-widget-test-flutter
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: flutter-add-widget-test
Source: https://github.com/flutter/agent-plugins/tree/main/skills/flutter-add-widget-test
Command: npx skills add https://github.com/flutter/agent-plugins --skill flutter-add-widget-test-flutter

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill addresses the complexity of writing boilerplate-heavy widget tests, ensuring that UI components render correctly and respond to user interactions as expected.

Core Features & Use Cases

  • Widget Tree Validation: Quickly verify that specific widgets appear in the UI with the correct properties.
  • Interaction Simulation: Automate complex user flows like text entry, button taps, scrolling, and dismissible gestures.
  • Use Case: When building a new feature, use this skill to generate a test file that validates the entire lifecycle of a component, from initial render to state-driven updates and animations.

Quick Start

Use the flutter-add-widget-test skill to generate a test file for the login screen that verifies the email field accepts input and the submit button triggers a loading state.

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 Flutter widget tests to verify UI rendering and user interactions?

Write Flutter widget tests using the WidgetTester API to verify UI rendering and user interactions by executing assertions against the widget tree. This approach validates expected UI behavior for both stateful and stateless widgets.

Can I simulate complex user gestures like text entry and scrolling in a Flutter widget test?

Yes, you can simulate complex user gestures in a Flutter widget test by automating interaction simulation. This includes automating user flows like text entry, button taps, scrolling, and dismissible gestures to validate component logic.

What is the best way to test asynchronous state updates in stateful Flutter widgets?

Testing asynchronous state updates in stateful Flutter widgets is handled by creating test suites that facilitate validation of state-driven updates. This uses the flutter_test package to execute assertions against the widget tree during these updates.

What do I need to set up before running component-level unit tests for a Flutter application?

To run component-level unit tests for a Flutter application, you need the flutter_test package included in your project setup. This package provides the required framework to execute assertions against the widget tree and validate expected UI behavior.

How does a widget tree validation test verify that specific UI components appear correctly?

Widget tree validation verifies that specific UI components appear correctly by executing assertions against the widget tree to check for specific widgets. This ensures the UI components render with the correct properties and expected behavior.

Why does my Flutter widget test fail to validate the entire lifecycle of a component from initial render?

Flutter widget tests validate the entire lifecycle of a component by generating a test file that covers initial render to state-driven updates and animations. Failure usually indicates missing assertions for asynchronous state updates or incomplete gesture simulation logic.