Use when adding new error messages to React, or seeing "unknown error code" warnings.
npx skills add rodydavis/skills --skill "flutter-control-and-screenshot"
Install specific skill from multi-skill repository
# Description
Guide on how to control a Flutter app using flutter_driver via MCP and capture screenshots.
# SKILL.md
name: flutter-control-and-screenshot
description: Guide on how to control a Flutter app using flutter_driver via MCP and capture screenshots.
Flutter Driver Control & Screenshot
This skill outlines the process of adding flutter_driver support to a Flutter application, launching it via the Dart MCP server, controlling it (tapping, finding widgets), and capturing screenshots (handling Web/Desktop specific constraints).
Prerequisites
- Dart MCP Server: Ensure the
dart-mcp-serveris active. - Flutter Project: You need a working Flutter project.
Step 1: Add Dependency
Add flutter_driver to the dev_dependencies in your pubspec.yaml.
dev_dependencies:
flutter_driver:
sdk: flutter
Run dart pub get or use the mcp_dart-mcp-server_pub tool.
Step 2: Create Driver Entry Point
Create a separate entry point, typically test_driver/app.dart, to enable the driver extension without polluting main.dart.
[!IMPORTANT]
Replaceyour_app_package_namewith the actual name of your package as defined inpubspec.yaml.
// test_driver/app.dart
import 'package:flutter_driver/driver_extension.dart';
import 'package:your_app_package_name/main.dart' as app; // Import your main app
void main() {
// Enable the extension
enableFlutterDriverExtension();
// Run the app
app.main();
}
Step 3: Launch App via MCP
Use the mcp_dart-mcp-server_launch_app tool.
target:test_driver/app.dartdevice:chrome(ormacos,linux,windows)root: Absolute path to your project root.
Note: The tool returns a DTD URI (Data Tooling Daemon) and a PID. Save these.
Step 4: Connect to DTD
Use mcp_dart-mcp-server_connect_dart_tooling_daemon with the URI returned from the launch step.
{
"uri": "ws://127.0.0.1:..."
}
Step 5: Web Screenshot Strategy (Browser Subagent)
If running on Web (Chrome), flutter_driver's screenshot command may not work or may not be supported directly in all environments. A robust fallback is to use the browser_subagent.
- Get App URL: Use
mcp_dart-mcp-server_get_app_logswith the app's PID. Look for lines likeA Dart VM Service on Chrome is available at: http://127.0.0.1:XXXXX. The app logs usually contain the local HTTP URL. - Navigate & Snapshot: Call
browser_subagent.- Task: "Navigate to [URL]. Wait for render. Take a screenshot."
Step 6: Control the App (Flutter Driver)
Use mcp_dart-mcp-server_flutter_driver to interact with the app.
- Get Widget Tree:
mcp_dart-mcp-server_get_widget_tree(useful to find keys/labels). - Tap:
json { "command": "tap", "finderType": "ByText", "text": "Settings" } - Scroll, Enter Text, etc. are also available.
Step 7: Cleanup
Always stop the app when done to free up ports and resources.
- Use
mcp_dart-mcp-server_stop_appwith the PID.
Example Workflow
- Launch
test_driver/app.dart. - Connect DTD.
- Log Check: Find localhost URL.
- Browser Subagent: Navigate & Screenshot (Home/Dashboard).
- Flutter Driver: Tap "Tasks" tab.
- Browser Subagent: Screenshot (Tasks).
- Flutter Driver: Tap "Settings" tab.
- Browser Subagent: Screenshot (Settings).
- Stop App.
# Supported AI Coding Agents
This skill is compatible with the SKILL.md standard and works with all major AI coding agents:
Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.