@bdayadev/flutter-ultra-mcp 1.11.7 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,171 @@
1
+ ---
2
+ name: add-widget-test
3
+ description: Implement a component-level test using `WidgetTester` to verify UI rendering and user interactions (tapping, scrolling, entering text). Use when validating that a specific widget displays correct data and responds to events as expected.
4
+ last_modified: Tue, 21 Apr 2026 21:15:41 GMT
5
+ ---
6
+
7
+ # Writing Flutter Widget Tests
8
+
9
+ ## Contents
10
+
11
+ - [Setup & Configuration](#setup--configuration)
12
+ - [Core Components](#core-components)
13
+ - [Workflow: Implementing a Widget Test](#workflow-implementing-a-widget-test)
14
+ - [Interaction & State Management](#interaction--state-management)
15
+ - [Examples](#examples)
16
+
17
+ ## Setup & Configuration
18
+
19
+ Ensure the testing environment is properly configured before authoring widget tests.
20
+
21
+ 1. Add the `flutter_test` dependency to the `dev_dependencies` section of `pubspec.yaml`.
22
+ 2. Place all test files in the `test/` directory at the root of the project.
23
+ 3. Suffix all test file names with `_test.dart` (e.g., `widget_test.dart`).
24
+
25
+ ## Core Components
26
+
27
+ Utilize the following `flutter_test` components to interact with and validate the widget tree:
28
+
29
+ - **`WidgetTester`**: The primary interface for building and interacting with widgets in the test environment. Provided automatically by the `testWidgets()` function.
30
+ - **`Finder`**: Locates widgets in the test environment (e.g., `find.text('Submit')`, `find.byType(TextField)`, `find.byKey(Key('submit_btn'))`).
31
+ - **`Matcher`**: Verifies the presence or state of widgets located by a `Finder` (e.g., `findsOneWidget`, `findsNothing`, `findsNWidgets(2)`, `matchesGoldenFile`).
32
+
33
+ ## Workflow: Implementing a Widget Test
34
+
35
+ Copy the following checklist to track progress when implementing a new widget test.
36
+
37
+ ### Task Progress
38
+
39
+ - [ ] **Step 1: Define the test.** Use `testWidgets('description', (WidgetTester tester) async { ... })`.
40
+ - [ ] **Step 2: Build the widget.** Call `await tester.pumpWidget(MyWidget())` to render the UI. Wrap the widget in a `MaterialApp` or `Directionality` widget if it requires inherited directional or theme data.
41
+ - [ ] **Step 3: Locate elements.** Instantiate `Finder` objects for the target widgets.
42
+ - [ ] **Step 4: Verify initial state.** Use `expect(finder, matcher)` to validate the initial render.
43
+ - [ ] **Step 5: Simulate interactions.** Execute gestures or inputs (e.g., `await tester.tap(buttonFinder)`).
44
+ - [ ] **Step 6: Rebuild the tree.** Call `await tester.pump()` or `await tester.pumpAndSettle()` to process state changes.
45
+ - [ ] **Step 7: Verify updated state.** Use `expect()` to validate the UI after the interaction.
46
+ - [ ] **Step 8: Run and validate.** Execute `flutter test test/your_test_file_test.dart`.
47
+ - [ ] **Step 9: Feedback Loop.** Review test output -> identify failing matchers -> adjust widget logic or test assertions -> re-run until passing.
48
+
49
+ ## Interaction & State Management
50
+
51
+ Apply the following conditional logic based on the type of interaction or state change being tested:
52
+
53
+ - **If testing static rendering:** Call `await tester.pumpWidget()` once, then immediately run `expect()` assertions.
54
+ - **If testing standard state changes (e.g., button taps):**
55
+ 1. Call `await tester.tap(finder)`.
56
+ 2. Call `await tester.pump()` to trigger a single frame rebuild.
57
+ - **If testing animations, transitions, or asynchronous UI updates:**
58
+ 1. Trigger the action (e.g., `await tester.drag(finder, Offset(500, 0))`).
59
+ 2. Call `await tester.pumpAndSettle()` to repeatedly pump frames until no more frames are scheduled (animation completes).
60
+ - **If testing text input:** Call `await tester.enterText(textFieldFinder, 'Input string')`.
61
+ - **If testing items in a dynamic or long list:** Call `await tester.scrollUntilVisible(itemFinder, 500.0, scrollable: listFinder)` to ensure the target widget is rendered before interacting with it.
62
+
63
+ ## Examples
64
+
65
+ ### High-Fidelity Widget Test Implementation
66
+
67
+ **Target Widget (`lib/todo_list.dart`):**
68
+
69
+ ```dart
70
+ import 'package:flutter/material.dart';
71
+
72
+ class TodoList extends StatefulWidget {
73
+ const TodoList({super.key});
74
+
75
+ @override
76
+ State<TodoList> createState() => _TodoListState();
77
+ }
78
+
79
+ class _TodoListState extends State<TodoList> {
80
+ final todos = <String>[];
81
+ final controller = TextEditingController();
82
+
83
+ @override
84
+ Widget build(BuildContext context) {
85
+ return MaterialApp(
86
+ home: Scaffold(
87
+ body: Column(
88
+ children: [
89
+ TextField(controller: controller),
90
+ Expanded(
91
+ child: ListView.builder(
92
+ itemCount: todos.length,
93
+ itemBuilder: (context, index) {
94
+ final todo = todos[index];
95
+ return Dismissible(
96
+ key: Key('$todo$index'),
97
+ onDismissed: (_) => setState(() => todos.removeAt(index)),
98
+ child: ListTile(title: Text(todo)),
99
+ );
100
+ },
101
+ ),
102
+ ),
103
+ ],
104
+ ),
105
+ floatingActionButton: FloatingActionButton(
106
+ onPressed: () {
107
+ setState(() {
108
+ todos.add(controller.text);
109
+ controller.clear();
110
+ });
111
+ },
112
+ child: const Icon(Icons.add),
113
+ ),
114
+ ),
115
+ );
116
+ }
117
+ }
118
+ ```
119
+
120
+ **Test Implementation (`test/todo_list_test.dart`):**
121
+
122
+ ```dart
123
+ import 'package:flutter/material.dart';
124
+ import 'package:flutter_test/flutter_test.dart';
125
+ import 'package:my_app/todo_list.dart';
126
+
127
+ void main() {
128
+ testWidgets('Add and remove a todo item', (WidgetTester tester) async {
129
+ // 1. Build the widget
130
+ await tester.pumpWidget(const TodoList());
131
+
132
+ // 2. Verify initial state
133
+ expect(find.byType(ListTile), findsNothing);
134
+
135
+ // 3. Enter text into the TextField
136
+ await tester.enterText(find.byType(TextField), 'Buy groceries');
137
+
138
+ // 4. Tap the add button
139
+ await tester.tap(find.byType(FloatingActionButton));
140
+
141
+ // 5. Rebuild the widget to reflect the new state
142
+ await tester.pump();
143
+
144
+ // 6. Verify the item was added
145
+ expect(find.text('Buy groceries'), findsOneWidget);
146
+
147
+ // 7. Swipe the item to dismiss it
148
+ await tester.drag(find.byType(Dismissible), const Offset(500, 0));
149
+
150
+ // 8. Build the widget until the dismiss animation ends
151
+ await tester.pumpAndSettle();
152
+
153
+ // 9. Verify the item was removed
154
+ expect(find.text('Buy groceries'), findsNothing);
155
+ });
156
+ }
157
+ ```
158
+
159
+ ## Flutter Ultra Integration
160
+
161
+ After writing the widget test, run and validate it with these tools:
162
+
163
+ - `mcp__plugin_flutter_flutter-ultra-build__start_run_widget_tests` — Execute widget tests (supports `testNamePattern` to scope)
164
+ - `mcp__plugin_flutter_flutter-ultra-build__poll_run_widget_tests` — Monitor test progress until completion
165
+ - `mcp__plugin_flutter_flutter-ultra-build__get_run_widget_tests_result` — Get detailed results: passed, failed, skipped, per-failure info
166
+ - `mcp__plugin_flutter_flutter-ultra-build__analyze` — Static analysis before running tests
167
+
168
+ ---
169
+
170
+ > **Attribution:** This skill is vendored from [flutter/skills](https://github.com/flutter/skills) (BSD-3-Clause).
171
+ > Synced by `scripts/sync-upstream-skills.mjs`. Do not edit manually — changes will be overwritten on next sync.
@@ -0,0 +1,182 @@
1
+ ---
2
+ name: apply-architecture-best-practices
3
+ description: Architects a Flutter application using the recommended layered approach (UI, Logic, Data). Use when structuring a new project or refactoring for scalability.
4
+ last_modified: Tue, 21 Apr 2026 20:11:20 GMT
5
+ ---
6
+
7
+ # Architecting Flutter Applications
8
+
9
+ ## Contents
10
+
11
+ - [Architectural Layers](#architectural-layers)
12
+ - [Project Structure](#project-structure)
13
+ - [Workflow: Implementing a New Feature](#workflow-implementing-a-new-feature)
14
+ - [Examples](#examples)
15
+
16
+ ## Architectural Layers
17
+
18
+ Enforce strict Separation of Concerns by dividing the application into distinct layers. Never mix UI rendering with business logic or data fetching.
19
+
20
+ ### UI Layer (Presentation)
21
+
22
+ Implement the MVVM (Model-View-ViewModel) pattern to manage UI state and logic.
23
+
24
+ - **Views:** Write reusable, lean widgets. Restrict logic in Views to UI-specific operations (e.g., animations, layout constraints, simple routing). Pass all required data from the ViewModel.
25
+ - **ViewModels:** Manage UI state and handle user interactions. Extend `ChangeNotifier` (or use `Listenable`) to expose state. Expose immutable state snapshots to the View. Inject Repositories into ViewModels via the constructor.
26
+
27
+ ### Data Layer
28
+
29
+ Implement the Repository pattern to isolate data access logic and create a single source of truth.
30
+
31
+ - **Services:** Create stateless classes to wrap external APIs (HTTP clients, local databases, platform plugins). Return raw API models or `Result` wrappers.
32
+ - **Repositories:** Consume one or more Services. Transform raw API models into clean Domain Models. Handle caching, offline synchronization, and retry logic. Expose Domain Models to ViewModels.
33
+
34
+ ### Logic Layer (Domain - Optional)
35
+
36
+ - **Use Cases:** Implement this layer only if the application contains complex business logic that clutters the ViewModel, or if logic must be reused across multiple ViewModels. Extract this logic into dedicated Use Case (interactor) classes that sit between ViewModels and Repositories.
37
+
38
+ ## Project Structure
39
+
40
+ Organize the codebase using a hybrid approach: group UI components by feature, and group Data/Domain components by type.
41
+
42
+ ```text
43
+ lib/
44
+ ├── data/
45
+ │ ├── models/ # API models
46
+ │ ├── repositories/ # Repository implementations
47
+ │ └── services/ # API clients, local storage wrappers
48
+ ├── domain/
49
+ │ ├── models/ # Clean domain models
50
+ │ └── use_cases/ # Optional business logic classes
51
+ └── ui/
52
+ ├── core/ # Shared widgets, themes, typography
53
+ └── features/
54
+ └── [feature_name]/
55
+ ├── view_models/
56
+ └── views/
57
+ ```
58
+
59
+ ## Workflow: Implementing a New Feature
60
+
61
+ Follow this sequential workflow when adding a new feature to the application. Copy the checklist to track progress.
62
+
63
+ ### Task Progress
64
+
65
+ - [ ] **Step 1: Define Domain Models.** Create immutable data classes for the feature using `freezed` or `built_value`.
66
+ - [ ] **Step 2: Implement Services.** Create or update Service classes to handle external API communication.
67
+ - [ ] **Step 3: Implement Repositories.** Create the Repository to consume Services and return Domain Models.
68
+ - [ ] **Step 4: Apply Conditional Logic (Domain Layer).**
69
+ - _If the feature requires complex data transformation or cross-repository logic:_ Create a Use Case class.
70
+ - _If the feature is a simple CRUD operation:_ Skip to Step 5.
71
+ - [ ] **Step 5: Implement the ViewModel.** Create the ViewModel extending `ChangeNotifier`. Inject required Repositories/Use Cases. Expose immutable state and command methods.
72
+ - [ ] **Step 6: Implement the View.** Create the UI widget. Use `ListenableBuilder` or `AnimatedBuilder` to listen to ViewModel changes.
73
+ - [ ] **Step 7: Inject Dependencies.** Register the new Service, Repository, and ViewModel in the dependency injection container (e.g., `provider` or `get_it`).
74
+ - [ ] **Step 8: Run Validator.** Execute unit tests for the ViewModel and Repository.
75
+ - _Feedback Loop:_ Run tests -> Review failures -> Fix logic -> Re-run until passing.
76
+
77
+ ## Examples
78
+
79
+ ### Data Layer: Service and Repository
80
+
81
+ ```dart
82
+ // 1. Service (Raw API interaction)
83
+ class ApiClient {
84
+ Future<UserApiModel> fetchUser(String id) async {
85
+ // HTTP GET implementation...
86
+ }
87
+ }
88
+
89
+ // 2. Repository (Single source of truth, returns Domain Model)
90
+ class UserRepository {
91
+ UserRepository({required ApiClient apiClient}) : _apiClient = apiClient;
92
+
93
+ final ApiClient _apiClient;
94
+ User? _cachedUser;
95
+
96
+ Future<User> getUser(String id) async {
97
+ if (_cachedUser != null) return _cachedUser!;
98
+
99
+ final apiModel = await _apiClient.fetchUser(id);
100
+ _cachedUser = User(id: apiModel.id, name: apiModel.fullName); // Transform to Domain Model
101
+ return _cachedUser!;
102
+ }
103
+ }
104
+ ```
105
+
106
+ ### UI Layer: ViewModel and View
107
+
108
+ ```dart
109
+ // 3. ViewModel (State management and presentation logic)
110
+ class ProfileViewModel extends ChangeNotifier {
111
+ ProfileViewModel({required UserRepository userRepository})
112
+ : _userRepository = userRepository;
113
+
114
+ final UserRepository _userRepository;
115
+
116
+ User? _user;
117
+ User? get user => _user;
118
+
119
+ bool _isLoading = false;
120
+ bool get isLoading => _isLoading;
121
+
122
+ Future<void> loadProfile(String id) async {
123
+ _isLoading = true;
124
+ notifyListeners();
125
+
126
+ try {
127
+ _user = await _userRepository.getUser(id);
128
+ } finally {
129
+ _isLoading = false;
130
+ notifyListeners();
131
+ }
132
+ }
133
+ }
134
+
135
+ // 4. View (Dumb UI component)
136
+ class ProfileView extends StatelessWidget {
137
+ const ProfileView({super.key, required this.viewModel});
138
+
139
+ final ProfileViewModel viewModel;
140
+
141
+ @override
142
+ Widget build(BuildContext context) {
143
+ return ListenableBuilder(
144
+ listenable: viewModel,
145
+ builder: (context, _) {
146
+ if (viewModel.isLoading) {
147
+ return const Center(child: CircularProgressIndicator());
148
+ }
149
+
150
+ final user = viewModel.user;
151
+ if (user == null) {
152
+ return const Center(child: Text('User not found'));
153
+ }
154
+
155
+ return Column(
156
+ children: [
157
+ Text(user.name),
158
+ ElevatedButton(
159
+ onPressed: () => viewModel.loadProfile(user.id),
160
+ child: const Text('Refresh'),
161
+ ),
162
+ ],
163
+ );
164
+ },
165
+ );
166
+ }
167
+ }
168
+ ```
169
+
170
+ ## Flutter Ultra Integration
171
+
172
+ Use these tools to audit and validate architectural decisions:
173
+
174
+ - `mcp__plugin_flutter_flutter-ultra-build__list_projects` — Discover all projects in the workspace
175
+ - `mcp__plugin_flutter_flutter-ultra-build__project_info` — Get project structure, dependencies, and entry points
176
+ - `mcp__plugin_flutter_flutter-ultra-build__analyze` — Run static analysis to catch architectural violations
177
+ - `mcp__plugin_flutter_flutter-ultra-build__pub_deps` — Review dependency graph for layering issues
178
+
179
+ ---
180
+
181
+ > **Attribution:** This skill is vendored from [flutter/skills](https://github.com/flutter/skills) (BSD-3-Clause).
182
+ > Synced by `scripts/sync-upstream-skills.mjs`. Do not edit manually — changes will be overwritten on next sync.
@@ -0,0 +1,200 @@
1
+ ---
2
+ name: build-cli-app
3
+ description: Entrypoint structure, exit codes, cross-platform scripts. Use when building command line utilities, scripts, or applications.
4
+ last_modified: Fri, 04 May 2026 17:41:00 GMT
5
+ ---
6
+
7
+ # Building Dart CLI Applications
8
+
9
+ ## Contents
10
+
11
+ - [Project Setup & Architecture](#project-setup--architecture)
12
+ - [Argument Parsing & Command Routing](#argument-parsing--command-routing)
13
+ - [Execution & Error Handling](#execution--error-handling)
14
+ - [Testing CLI Applications](#testing-cli-applications)
15
+ - [Compilation & Distribution](#compilation--distribution)
16
+ - [Workflows](#workflows)
17
+ - [Examples](#examples)
18
+
19
+ ## Project Setup & Architecture
20
+
21
+ Initialize new CLI projects using the official Dart template to ensure standard directory structures.
22
+
23
+ - Run `dart create -t cli <project_name>` to scaffold a console application with basic argument parsing.
24
+ - Place executable entry points (files containing `main()`) exclusively in the `bin/` directory.
25
+ - Place internal implementation logic in `lib/src/` and expose public APIs via `lib/<project_name>.dart`.
26
+ - Enforce formatting in CI environments by running `dart format . --set-exit-if-changed`. This returns exit code 1 if formatting violations exist.
27
+
28
+ ## Argument Parsing & Command Routing
29
+
30
+ Import the `args` package to manage command-line arguments, flags, and subcommands.
31
+
32
+ - If building a simple script: Use `ArgParser` directly to define flags (`addFlag`) and options (`addOption`).
33
+ - If building a complex, multi-command CLI (like `git`): Implement `CommandRunner` and extend `Command` for each subcommand.
34
+ - Define global arguments on the `CommandRunner.argParser` and command-specific arguments on the individual `Command.argParser`.
35
+ - Catch `UsageException` to gracefully handle invalid arguments and display the automatically generated help text.
36
+ - **Validate Help Text Accuracy**: Ensure the help text provides all necessary information to run the tool. If the help text references a compiled executable name, and the user needs to add it to their PATH to run it that way, provide clear instructions on how to do so in the help text or description.
37
+
38
+ ## Execution & Error Handling
39
+
40
+ Leverage the `io` and `stack_trace` packages to build robust, production-ready CLI tools.
41
+
42
+ - Use the `io` package's `ExitCode` enum to return standard POSIX exit codes (e.g., `ExitCode.success.code`, `ExitCode.usage.code`).
43
+ - Use `sharedStdIn` from the `io` package if multiple asynchronous listeners need sequential access to standard input.
44
+ - Wrap the application execution in `Chain.capture()` from the `stack_trace` package to track asynchronous stack chains.
45
+ - Format output stack traces using `Trace.terse` or `Chain.terse` to strip noisy core library frames and present readable errors to the user.
46
+ - **Do not swallow exceptions** in lower-level logic or storage classes unless recovery is possible. Let them bubble up or rethrow them so higher-level commands know operations failed.
47
+ - **Fail fast and with non-zero exit codes**: Ensure operation failures result in descriptive error messages to `stderr` and appropriate non-zero exit codes (e.g., using `exit(1)` or triggering a 64 exit code after a caught `UsageException`).
48
+
49
+ ## Testing CLI Applications
50
+
51
+ > [!IMPORTANT]
52
+ > **All new commands and significant features must be covered by automated tests.** Manual verification is not sufficient for testing logic. However, manual verification of help text and user experience (UX) is still required to ensure the interface is intuitive and correct.
53
+
54
+ Use `test_process` and `test_descriptor` to write high-fidelity integration tests for your CLI.
55
+
56
+ - Define expected filesystem states using `test_descriptor` (`d.dir`, `d.file`).
57
+ - Create the mock filesystem before execution using `await d.Descriptor.create()`.
58
+ - Spawn the CLI process using `TestProcess.start('dart', ['run', 'bin/cli.dart', ...args])`.
59
+ - Validate standard output and error streams using `StreamQueue` matchers (e.g., `emitsThrough`, `emits`).
60
+ - Assert the final exit code using `await process.shouldExit(0)`.
61
+ - Validate resulting filesystem mutations using `await d.Descriptor.validate()`.
62
+
63
+ ## Compilation & Distribution
64
+
65
+ Select the appropriate compilation target based on your distribution requirements.
66
+
67
+ - **If testing locally during development:** Use `dart run bin/cli.dart`. This uses the JIT compiler for rapid iteration.
68
+ - **If bundling code assets and dynamic libraries:** Use `dart build cli`. This runs build hooks and outputs to `build/cli/_/bundle/`.
69
+ - **If distributing a standalone native executable:** Use `dart compile exe bin/cli.dart -o <output_path>`. This bundles the Dart runtime and machine code into a single file.
70
+ - **If distributing multiple apps with strict disk space limits:** Use `dart compile aot-snapshot bin/cli.dart`. Run the resulting `.aot` file using `dartaotruntime`.
71
+
72
+ <details>
73
+ <summary>Cross-Compilation Targets (Linux Only)</summary>
74
+
75
+ Dart supports cross-compiling to Linux from macOS, Windows, or Linux hosts.
76
+ Use the `--target-os` and `--target-arch` flags with `dart compile exe` or `dart compile aot-snapshot`.
77
+
78
+ - `--target-os=linux` (Only Linux is currently supported as a cross-compilation target)
79
+ - `--target-arch=arm64` (64-bit ARM)
80
+ - `--target-arch=x64` (x86-64)
81
+ - `--target-arch=arm` (32-bit ARM)
82
+ - `--target-arch=riscv64` (64-bit RISC-V)
83
+
84
+ Example: `dart compile exe --target-os=linux --target-arch=arm64 bin/cli.dart`
85
+
86
+ </details>
87
+
88
+ ## Workflows
89
+
90
+ ### Task Progress: Implement a New CLI Command
91
+
92
+ - [ ] Create a new class extending `Command` in `lib/src/commands/`.
93
+ - [ ] Define the `name` and `description` properties.
94
+ - [ ] Register command-specific flags in the constructor using `argParser.addFlag()` or `argParser.addOption()`.
95
+ - [ ] Implement the `run()` method with the core logic.
96
+ - [ ] Register the new command in the `CommandRunner` instance in `bin/cli.dart` using `addCommand()`.
97
+ - [ ] Create tests for the new command in the `test/` directory using `test_process` or standard tests.
98
+ - [ ] Run validator -> Execute `dart run bin/cli.dart help <command_name>` to verify help text generation.
99
+ - [ ] Verify final UX: Compile the application using `dart compile exe` and run the resulting executable to verify the target user experience (e.g., `./bin/cli <command>`).
100
+
101
+ ### Task Progress: Compile and Release Native Executable
102
+
103
+ - [ ] Run validator -> Execute `dart format . --set-exit-if-changed` to ensure code formatting.
104
+ - [ ] Run validator -> Execute `dart analyze` to ensure no static analysis errors.
105
+ - [ ] Run validator -> Execute `dart test` to pass all integration tests.
106
+ - [ ] Compile for host OS: `dart compile exe bin/cli.dart -o build/cli-host`
107
+ - [ ] Compile for Linux (if host is macOS/Windows): `dart compile exe --target-os=linux --target-arch=x64 bin/cli.dart -o build/cli-linux-x64`
108
+
109
+ ## Examples
110
+
111
+ ### Example: CommandRunner Implementation
112
+
113
+ ```dart
114
+ import 'dart:io';
115
+ import 'package:args/command_runner.dart';
116
+ import 'package:stack_trace/stack_trace.dart';
117
+
118
+ class CommitCommand extends Command {
119
+ @override
120
+ final String name = 'commit';
121
+ @override
122
+ final String description = 'Record changes to the repository.';
123
+
124
+ CommitCommand() {
125
+ argParser.addFlag('all', abbr: 'a', help: 'Commit all changed files.');
126
+ }
127
+
128
+ @override
129
+ Future<void> run() async {
130
+ final commitAll = argResults?['all'] as bool? ?? false;
131
+ print('Committing... (All: $commitAll)');
132
+ }
133
+ }
134
+
135
+ void main(List<String> args) {
136
+ Chain.capture(() async {
137
+ final runner = CommandRunner('dgit', 'Distributed version control.')
138
+ ..addCommand(CommitCommand());
139
+
140
+ await runner.run(args);
141
+ }, onError: (error, chain) {
142
+ if (error is UsageException) {
143
+ stderr.writeln(error.message);
144
+ stderr.writeln(error.usage);
145
+ exit(64); // ExitCode.usage.code
146
+ } else {
147
+ stderr.writeln('Fatal error: $error');
148
+ stderr.writeln(chain.terse);
149
+ exit(1);
150
+ }
151
+ });
152
+ }
153
+ ```
154
+
155
+ ### Example: Integration Testing with Subprocesses
156
+
157
+ ```dart
158
+ import 'package:test/test.dart';
159
+ import 'package:test_process/test_process.dart';
160
+ import 'package:test_descriptor/test_descriptor.dart' as d;
161
+
162
+ void main() {
163
+ test('CLI formats output correctly and modifies filesystem', () async {
164
+ // 1. Setup mock filesystem
165
+ await d.dir('project', [
166
+ d.file('config.json', '{"key": "value"}')
167
+ ]).create();
168
+
169
+ // 2. Spawn the CLI process
170
+ final process = await TestProcess.start(
171
+ 'dart',
172
+ ['run', 'bin/cli.dart', 'process', '--path', '${d.sandbox}/project']
173
+ );
174
+
175
+ // 3. Validate stdout stream
176
+ await expectLater(process.stdout, emitsThrough('Processing complete.'));
177
+
178
+ // 4. Validate exit code
179
+ await process.shouldExit(0);
180
+
181
+ // 5. Validate filesystem mutations
182
+ await d.dir('project', [
183
+ d.file('config.json', '{"key": "value"}'),
184
+ d.file('output.log', 'Success')
185
+ ]).validate();
186
+ });
187
+ }
188
+ ```
189
+
190
+ ## Flutter Ultra Integration
191
+
192
+ Use these tools to validate the CLI app structure:
193
+
194
+ - `mcp__plugin_flutter_flutter-ultra-build__analyze` — Static analysis on the CLI project
195
+ - `mcp__plugin_flutter_flutter-ultra-build__pub_deps` — Review dependency tree
196
+
197
+ ---
198
+
199
+ > **Attribution:** This skill is vendored from [dart-lang/skills](https://github.com/dart-lang/skills) (BSD-3-Clause).
200
+ > Synced by `scripts/sync-upstream-skills.mjs`. Do not edit manually — changes will be overwritten on next sync.