Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "dart-flutter",
"owner": {
"name": "Dart and Flutter Team",
"email": "stores@flutter.io"
},
"description": "Official Claude Marketplace for Dart and Flutter plugins",
"plugins": [
{
"name": "dart-flutter",
"description": "The official Claude plugin for Dart and Flutter that installs Flutter/Dart Skills and Dart MCP server for building natively compiled, visually stunning applications for mobile, web, desktop, and embedded devices from a single codebase",
"category": "development",
"tags": [
"dart",
"flutter",
"mobile"
],
"source": "./"
}
]
}
18 changes: 18 additions & 0 deletions .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "dart-flutter",
"displayName": "Dart and Flutter",
"version": "1.0.0",
"description": "Official Claude plugin for Dart and Flutter that installs Flutter/Dart Skills and Dart MCP server for building natively compiled, visually stunning applications for mobile, web, desktop, and embedded devices from a single codebase",
"author": {
"name": "Dart and Flutter",
"url": "https://flutter.dev"
},
"homepage": "https://github.com/flutter/agent-plugins",
"repository": "https://github.com/flutter/agent-plugins",
"license": "BSD-3-Clause",
"keywords": [
"flutter",
"dart",
"mobile"
]
}
76 changes: 76 additions & 0 deletions .github/workflows/sync_skills.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: Sync Skills Directory via Git Hash (Dart)

on:
schedule:
- cron: '0 0 * * *' # Keep the daily check as a fallback safety net
workflow_dispatch: # Keep manual run capability
repository_dispatch:
types: [dart-skills-updated] # Listen for this custom ping
jobs:
sync:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout Flutter Skills (Destination)
uses: actions/checkout@v4
with:
# Falls back to the default GITHUB_TOKEN if SYNC_PAT is not defined
token: ${{ secrets.SYNC_PAT || github.token }}
path: dest_repo

- name: Checkout Dart Skills (Source)
uses: actions/checkout@v4
with:
repository: dart-lang/skills
fetch-depth: 50
path: src_repo

- name: Setup Dart Environment
uses: dart-lang/setup-dart@v1
with:
sdk: stable

- name: Execute Dart Sync Engine
id: sync_engine
# Continue on error so we can check if it exited early via code 10
continue-on-error: true
run: |
cd dest_repo
# Run our compiled-on-the-fly Dart script
dart run tool/sync_skills.dart ../src_repo skills
EXIT_CODE=$?

if [ $EXIT_CODE -eq 0 ]; then
echo "changes_detected=true" >> $GITHUB_OUTPUT
elif [ $EXIT_CODE -eq 10 ]; then
echo "changes_detected=false" >> $GITHUB_OUTPUT
echo "✅ Dart script signaled NO changes were found. Stopping workflow."
else

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silent Failure Bug
GitHub Actions run bash scripts with set -e by default. If dart run exits with 10 (no changes) or 1 (real error), the bash script will immediately terminate on this line. It will never execute EXIT_CODE=$? or the if/else block below it.

Because continue-on-error: true is set on the step, the step will still be marked as green, changes_detected won't be set, and the PR creation step will be skipped. This means real errors (exit code 1) will be silently swallowed and ignored.

The Fix: Remove continue-on-error: true and handle the exit code directly so set -e doesn't abort the script. For example:

      - name: Execute Dart Sync Engine
        id: sync_engine
        run: |
          cd dest_repo
          
          # Temporarily disable exit on error to capture the exit code
          set +e
          dart run tool/sync_skills.dart ../src_repo skills
          EXIT_CODE=$?
          set -e
          
          if [ $EXIT_CODE -eq 0 ]; then
            echo "changes_detected=true" >> $GITHUB_OUTPUT
          elif [ $EXIT_CODE -eq 10 ]; then
            echo "changes_detected=false" >> $GITHUB_OUTPUT
            echo "✅ Dart script signaled NO changes were found. Stopping workflow."
          else
            echo "❌ Dart script failed with error code $EXIT_CODE"
            exit $EXIT_CODE
          fi

echo "❌ Dart script failed with error code $EXIT_CODE"
exit $EXIT_CODE
fi

- name: Create Pull Request
if: steps.sync_engine.outputs.changes_detected == 'true'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.SYNC_PAT || github.token }}
path: dest_repo
branch: automation/sync-dart-skills
title: "🤖 chore: sync skills directory from dart-lang/skills"
commit-message: "chore: auto-sync skills directory from dart-lang/skills"
body: |
### 🤖 Automated Skills Sync & Version Bump (Dart Powered)
This is an automated pull request to sync the contents of the `skills/` directory from [dart-lang/skills](https://github.com/dart-lang/skills).

This run used a state-tracked Git hash (`.dart_skills_githash`) computed directly by our custom **Dart synchronization utility** (`tool/sync_skills.dart`).

### 🛠️ Changes Performed:
* **Preserved:** All native `flutter/*` skills in the repository remain unchanged.
* **Synced:** All new, modified, or deleted files inside `dart-lang/skills` have been carried over.
* **Bumped:** Automatically incremented the plugin version field in `.claude-plugin/plugin.json` to keep integrations updated.
labels: |
automated-pr
sync
11 changes: 11 additions & 0 deletions .mcp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"mcpServers": {
"dart-mcp-server": {
"command": "dart",
"args": [
"mcp-server"
],
"env": {}
}
}
}
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,26 @@ folder that most agents use.
npx skills add flutter/agent-plugins --skill '*' --agent universal --yes
```

### Claude Code Plugin

1. Add the marketplace for Claude Code plugins:

```bash
claude plugin marketplace add flutter/agent-plugins
```

2. Install the Claude plugin for Dart and Flutter:

```bash
claude plugin install dart-flutter@dart-flutter
```

3. Verify the installation:

```bash
claude plugin marketplace list
```

## Updating Plugins

To update, run the following command:
Expand Down
122 changes: 122 additions & 0 deletions skills/dart-add-unit-test/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
---
name: dart-add-unit-test
description: Write and organize unit tests for functions, methods, and classes using `package:test`. Use when creating new logic or fixing bugs to ensure code remains correct and regression-free.
metadata:
model: models/gemini-3.1-pro-preview
last_modified: Fri, 24 Apr 2026 15:07:58 GMT
---
# Testing Dart and Flutter Applications

## Contents
- [Structuring Test Files](#structuring-test-files)
- [Writing Tests](#writing-tests)
- [Executing Tests](#executing-tests)
- [Test Implementation Workflow](#test-implementation-workflow)
- [Examples](#examples)

## Structuring Test Files
Organize test files to mirror the `lib` directory structure to maintain predictability.

* Place all test code within the `test` directory at the root of the package.
* Append `_test.dart` to the end of all test file names (e.g., `lib/src/utils.dart` should be tested in `test/src/utils_test.dart`).
* If writing integration tests, place them in an `integration_test` directory at the root of the package.

## Writing Tests
Utilize `package:test` as the standard testing library for Dart applications.

* Import `package:test/test.dart` (or `package:flutter_test/flutter_test.dart` for Flutter).
* Group related tests using the `group()` function to provide shared context.
* Define individual test cases using the `test()` function.
* Validate outcomes using the `expect()` function alongside matchers (e.g., `equals()`, `isTrue`, `throwsA()`).
* Write asynchronous tests using standard `async`/`await` syntax. The test runner automatically waits for the `Future` to complete.
* Manage test setup and teardown using `setUp()` and `tearDown()` callbacks.
* If testing code that relies on dependency injection, use `package:mockito` alongside `package:test` to generate mock objects, configure fixed scenarios, and verify interactions.

## Executing Tests
Select the appropriate test runner based on the project type and test location.

* If working on a pure Dart project, execute tests using the `dart test` command.
* If working on a Flutter project, execute tests using the `flutter test` command.
* If running integration tests, explicitly specify the directory path, as the default runner ignores it: `dart test integration_test` or `flutter test integration_test`.

## Test Implementation Workflow

Follow this sequential workflow when implementing new test suites. Copy the checklist to track your progress.

### Task Progress
- [ ] 1. Create the test file in the `test/` directory, ensuring the `_test.dart` suffix.
- [ ] 2. Import `package:test/test.dart` and the target library.
- [ ] 3. Define a `main()` function.
- [ ] 4. Initialize shared resources or mocks using `setUp()`.
- [ ] 5. Write `test()` cases grouped by functionality using `group()`.
- [ ] 6. Execute the test suite using the appropriate CLI command.
- [ ] 7. **Feedback Loop**: Run test -> Review stack trace for failures -> Fix implementation or assertions -> Re-run until passing.

## Examples

### Standard Unit Test Suite
Demonstrates grouping, setup, synchronous, and asynchronous testing.

```dart
import 'package:test/test.dart';
import 'package:my_package/calculator.dart';
void main() {
group('Calculator', () {
late Calculator calc;
setUp(() {
calc = Calculator();
});
test('adds two numbers correctly', () {
expect(calc.add(2, 3), equals(5));
});
test('handles asynchronous operations', () async {
final result = await calc.fetchRemoteValue();
expect(result, isNotNull);
expect(result, greaterThan(0));
});
});
}
```

### Mocking with Mockito
Demonstrates configuring a mock object for dependency injection testing.

```dart
import 'package:test/test.dart';
import 'package:mockito/mockito.dart';
import 'package:mockito/annotations.dart';
import 'package:my_package/api_client.dart';
import 'package:my_package/data_service.dart';
// Generate the mock using build_runner: dart run build_runner build
@GenerateNiceMocks([MockSpec<ApiClient>()])
import 'data_service_test.mocks.dart';
void main() {
group('DataService', () {
late MockApiClient mockApiClient;
late DataService dataService;
setUp(() {
mockApiClient = MockApiClient();
dataService = DataService(apiClient: mockApiClient);
});
test('returns parsed data on successful API call', () async {
// Configure the mock
when(mockApiClient.get('/data')).thenAnswer((_) async => '{"id": 1}');
// Execute the system under test
final result = await dataService.fetchData();
// Verify outcomes and interactions
expect(result.id, equals(1));
verify(mockApiClient.get('/data')).called(1);
});
});
}
```
Loading
Loading