sdd-full 4.8.0 → 4.8.2

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.
Files changed (164) hide show
  1. package/bin.js +2 -2
  2. package/index.js +18 -12
  3. package/package.json +1 -1
  4. package/skills/README.md +155 -47
  5. package/skills/design-planning/ai-coding-rules/SKILL.md +13 -5
  6. package/skills/design-planning/design-to-code/SKILL.md +14 -5
  7. package/skills/design-planning/enterprise-spec/SKILL.md +13 -5
  8. package/skills/design-planning/flutter-av/SKILL.md +16 -5
  9. package/skills/design-planning/flutter-map/SKILL.md +14 -5
  10. package/skills/design-planning/function-sdd/SKILL.md +13 -5
  11. package/skills/design-planning/global-overlay-stack-standard/SKILL.md +14 -4
  12. package/skills/design-planning/ui-motion-interaction-standard/SKILL.md +14 -4
  13. package/skills/design-planning/ui-sdd-specialized/SKILL.md +14 -5
  14. package/skills/development-execution/flutter-errors/SKILL.md +15 -5
  15. package/skills/quality-assurance/bdd-acceptance/SKILL.md +14 -5
  16. package/skills/quality-assurance/flutter-test/SKILL.md +16 -5
  17. package/skills/requirement-analysis/sdd/mock_sdd.md +156 -0
  18. package/skills/rules/project_rules.md +127 -538
  19. package/skills/rules/user_rules.md +263 -0
  20. package/skills/special-tools/env-check/SKILL.md +13 -5
  21. package/skills/special-tools/ios-full-auto-debug/SKILL.md +15 -5
  22. package/skills/VERSION.md +0 -310
  23. package/skills/flutter-skills/.github/dependabot.yaml +0 -15
  24. package/skills/flutter-skills/.github/workflows/dart_skills_lint_workflow.yaml +0 -68
  25. package/skills/flutter-skills/.github/workflows/skills_tool.yaml +0 -51
  26. package/skills/flutter-skills/CODE_OF_CONDUCT.md +0 -3
  27. package/skills/flutter-skills/CONTRIBUTING.md +0 -36
  28. package/skills/flutter-skills/LICENSE +0 -26
  29. package/skills/flutter-skills/README.md +0 -50
  30. package/skills/flutter-skills/pubspec.yaml +0 -9
  31. package/skills/flutter-skills/resources/flutter_skills.yaml +0 -434
  32. package/skills/flutter-skills/skills/flutter-add-integration-test/SKILL.md +0 -163
  33. package/skills/flutter-skills/skills/flutter-add-widget-preview/SKILL.md +0 -145
  34. package/skills/flutter-skills/skills/flutter-add-widget-test/SKILL.md +0 -154
  35. package/skills/flutter-skills/skills/flutter-apply-architecture-best-practices/SKILL.md +0 -162
  36. package/skills/flutter-skills/skills/flutter-build-responsive-layout/SKILL.md +0 -139
  37. package/skills/flutter-skills/skills/flutter-fix-layout-issues/SKILL.md +0 -130
  38. package/skills/flutter-skills/skills/flutter-implement-json-serialization/SKILL.md +0 -153
  39. package/skills/flutter-skills/skills/flutter-setup-declarative-routing/SKILL.md +0 -255
  40. package/skills/flutter-skills/skills/flutter-setup-localization/SKILL.md +0 -210
  41. package/skills/flutter-skills/skills/flutter-use-http-package/SKILL.md +0 -175
  42. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/add-dart-lint-validation-rule/SKILL.md +0 -196
  43. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-best-practices/SKILL.md +0 -65
  44. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-checks-migration/SKILL.md +0 -158
  45. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-cli-app-best-practices/SKILL.md +0 -168
  46. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-doc-validation/SKILL.md +0 -87
  47. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-long-lines/SKILL.md +0 -101
  48. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-matcher-best-practices/SKILL.md +0 -136
  49. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-modern-features/SKILL.md +0 -266
  50. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-package-maintenance/SKILL.md +0 -92
  51. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-test-coverage/SKILL.md +0 -92
  52. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-test-coverage/example/lib/src/calculator.dart +0 -7
  53. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-test-coverage/example/pubspec.yaml +0 -8
  54. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-test-coverage/example/test/calculator_test.dart +0 -11
  55. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-test-coverage/scripts/interpret_coverage.dart +0 -95
  56. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-test-coverage/scripts/pubspec.yaml +0 -6
  57. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-test-coverage/scripts/test/interpret_coverage_test.dart +0 -93
  58. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-test-fundamentals/SKILL.md +0 -173
  59. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/definition-of-done/SKILL.md +0 -27
  60. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/flutter_skills_ignore.json +0 -3
  61. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/grill-me/SKILL.md +0 -10
  62. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/ignore.json +0 -3
  63. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/test-driven-development/SKILL.md +0 -371
  64. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/test-driven-development/testing-anti-patterns.md +0 -299
  65. package/skills/flutter-skills/tool/dart_skills_lint/AUTHORS +0 -7
  66. package/skills/flutter-skills/tool/dart_skills_lint/CHANGELOG.md +0 -12
  67. package/skills/flutter-skills/tool/dart_skills_lint/CONTRIBUTING.md +0 -51
  68. package/skills/flutter-skills/tool/dart_skills_lint/LICENSE +0 -27
  69. package/skills/flutter-skills/tool/dart_skills_lint/README.md +0 -203
  70. package/skills/flutter-skills/tool/dart_skills_lint/analysis_options.yaml +0 -296
  71. package/skills/flutter-skills/tool/dart_skills_lint/bench/README.md +0 -23
  72. package/skills/flutter-skills/tool/dart_skills_lint/bench/baseline_throughput.dart +0 -230
  73. package/skills/flutter-skills/tool/dart_skills_lint/bin/cli.dart +0 -10
  74. package/skills/flutter-skills/tool/dart_skills_lint/dart_skills_lint.yaml +0 -14
  75. package/skills/flutter-skills/tool/dart_skills_lint/documentation/feature_design_docs/PRODUCTION_READYNESS.md +0 -48
  76. package/skills/flutter-skills/tool/dart_skills_lint/documentation/feature_design_docs/completion_migration_plan.md +0 -99
  77. package/skills/flutter-skills/tool/dart_skills_lint/documentation/feature_design_docs/legacy_patterns_report.md +0 -110
  78. package/skills/flutter-skills/tool/dart_skills_lint/documentation/feature_design_docs/pub_vs_skill_report.md +0 -56
  79. package/skills/flutter-skills/tool/dart_skills_lint/documentation/knowledge/SPECIFICATION.md +0 -79
  80. package/skills/flutter-skills/tool/dart_skills_lint/documentation/knowledge/architecture_overview.md +0 -64
  81. package/skills/flutter-skills/tool/dart_skills_lint/lib/dart_skills_lint.dart +0 -11
  82. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/config_parser.dart +0 -156
  83. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/entry_point.dart +0 -354
  84. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/fixable_rule.dart +0 -20
  85. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/models/analysis_severity.dart +0 -15
  86. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/models/check_type.dart +0 -17
  87. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/models/ignore_entry.dart +0 -34
  88. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/models/ignore_entry.g.dart +0 -19
  89. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/models/skill_context.dart +0 -27
  90. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/models/skill_rule.dart +0 -27
  91. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/models/skills_ignores.dart +0 -26
  92. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/models/skills_ignores.g.dart +0 -24
  93. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/models/validation_error.dart +0 -31
  94. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/rule_registry.dart +0 -79
  95. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/rules/absolute_paths_rule.dart +0 -74
  96. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/rules/description_length_rule.dart +0 -49
  97. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/rules/disallowed_field_rule.dart +0 -61
  98. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/rules/name_format_rule.dart +0 -167
  99. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/rules/relative_paths_rule.dart +0 -72
  100. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/rules/trailing_whitespace_rule.dart +0 -93
  101. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/rules/valid_yaml_metadata_rule.dart +0 -74
  102. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/skills_ignores_storage.dart +0 -36
  103. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/validation_session.dart +0 -559
  104. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/validator.dart +0 -238
  105. package/skills/flutter-skills/tool/dart_skills_lint/pubspec.yaml +0 -28
  106. package/skills/flutter-skills/tool/dart_skills_lint/skills/README.md +0 -10
  107. package/skills/flutter-skills/tool/dart_skills_lint/skills/dart-skills-lint-validation/SKILL.md +0 -195
  108. package/skills/flutter-skills/tool/dart_skills_lint/skills-lock.json +0 -75
  109. package/skills/flutter-skills/tool/dart_skills_lint/test/absolute_paths_test.dart +0 -167
  110. package/skills/flutter-skills/tool/dart_skills_lint/test/cli_integration_test.dart +0 -683
  111. package/skills/flutter-skills/tool/dart_skills_lint/test/config_file_test.dart +0 -292
  112. package/skills/flutter-skills/tool/dart_skills_lint/test/custom_rule_test.dart +0 -122
  113. package/skills/flutter-skills/tool/dart_skills_lint/test/directory_structure_test.dart +0 -163
  114. package/skills/flutter-skills/tool/dart_skills_lint/test/field_constraints_test.dart +0 -178
  115. package/skills/flutter-skills/tool/dart_skills_lint/test/fixer_test.dart +0 -172
  116. package/skills/flutter-skills/tool/dart_skills_lint/test/ignore_models_test.dart +0 -63
  117. package/skills/flutter-skills/tool/dart_skills_lint/test/metadata_validation_test.dart +0 -116
  118. package/skills/flutter-skills/tool/dart_skills_lint/test/relative_path_flag_test.dart +0 -70
  119. package/skills/flutter-skills/tool/dart_skills_lint/test/relative_paths_test.dart +0 -172
  120. package/skills/flutter-skills/tool/dart_skills_lint/test/resolve_rules_test.dart +0 -82
  121. package/skills/flutter-skills/tool/dart_skills_lint/test/rule_naming_test.dart +0 -29
  122. package/skills/flutter-skills/tool/dart_skills_lint/test/skills_ignores_storage_test.dart +0 -89
  123. package/skills/flutter-skills/tool/dart_skills_lint/test/test_utils.dart +0 -19
  124. package/skills/flutter-skills/tool/dart_skills_lint/test/trailing_whitespace_test.dart +0 -152
  125. package/skills/flutter-skills/tool/generator/README.md +0 -150
  126. package/skills/flutter-skills/tool/generator/analysis_options.yaml +0 -143
  127. package/skills/flutter-skills/tool/generator/bin/skills.dart +0 -73
  128. package/skills/flutter-skills/tool/generator/lib/src/commands/base_skill_command.dart +0 -87
  129. package/skills/flutter-skills/tool/generator/lib/src/commands/base_yaml_command.dart +0 -83
  130. package/skills/flutter-skills/tool/generator/lib/src/commands/generate_skill_command.dart +0 -92
  131. package/skills/flutter-skills/tool/generator/lib/src/commands/update_readme_command.dart +0 -150
  132. package/skills/flutter-skills/tool/generator/lib/src/commands/update_skill_command.dart +0 -97
  133. package/skills/flutter-skills/tool/generator/lib/src/commands/validate_skill_command.dart +0 -284
  134. package/skills/flutter-skills/tool/generator/lib/src/models/skill_params.dart +0 -41
  135. package/skills/flutter-skills/tool/generator/lib/src/services/gemini_service.dart +0 -310
  136. package/skills/flutter-skills/tool/generator/lib/src/services/markdown_converter.dart +0 -226
  137. package/skills/flutter-skills/tool/generator/lib/src/services/prompts.dart +0 -72
  138. package/skills/flutter-skills/tool/generator/lib/src/services/resource_fetcher_service.dart +0 -84
  139. package/skills/flutter-skills/tool/generator/lib/src/services/skill_instructions.dart +0 -30
  140. package/skills/flutter-skills/tool/generator/pubspec.yaml +0 -32
  141. package/skills/flutter-skills/tool/generator/test/commands/base_skill_command_test.dart +0 -131
  142. package/skills/flutter-skills/tool/generator/test/commands/validate_skills_input_test.dart +0 -263
  143. package/skills/flutter-skills/tool/generator/test/custom_skill_rules/last_modified_rule.dart +0 -32
  144. package/skills/flutter-skills/tool/generator/test/generate_skills_retry_test.dart +0 -105
  145. package/skills/flutter-skills/tool/generator/test/generate_skills_test.dart +0 -519
  146. package/skills/flutter-skills/tool/generator/test/lint_skills_test.dart +0 -34
  147. package/skills/flutter-skills/tool/generator/test/markdown_converter_test.dart +0 -103
  148. package/skills/flutter-skills/tool/generator/test/markdown_table_test.dart +0 -131
  149. package/skills/flutter-skills/tool/generator/test/models/skill_params_test.dart +0 -37
  150. package/skills/flutter-skills/tool/generator/test/services/gemini_service_test.dart +0 -291
  151. package/skills/flutter-skills/tool/generator/test/services/markdown_converter_test.dart +0 -156
  152. package/skills/flutter-skills/tool/generator/test/services/resource_fetcher_service_test.dart +0 -188
  153. package/skills/flutter-skills/tool/generator/test/update_skills_test.dart +0 -241
  154. package/skills/flutter-skills/tool/generator/test/validate_skills_test.dart +0 -728
  155. /package/skills/{.agents → flutter}/skills/flutter-add-integration-test/SKILL.md +0 -0
  156. /package/skills/{.agents → flutter}/skills/flutter-add-widget-preview/SKILL.md +0 -0
  157. /package/skills/{.agents → flutter}/skills/flutter-add-widget-test/SKILL.md +0 -0
  158. /package/skills/{.agents → flutter}/skills/flutter-apply-architecture-best-practices/SKILL.md +0 -0
  159. /package/skills/{.agents → flutter}/skills/flutter-build-responsive-layout/SKILL.md +0 -0
  160. /package/skills/{.agents → flutter}/skills/flutter-fix-layout-issues/SKILL.md +0 -0
  161. /package/skills/{.agents → flutter}/skills/flutter-implement-json-serialization/SKILL.md +0 -0
  162. /package/skills/{.agents → flutter}/skills/flutter-setup-declarative-routing/SKILL.md +0 -0
  163. /package/skills/{.agents → flutter}/skills/flutter-setup-localization/SKILL.md +0 -0
  164. /package/skills/{.agents → flutter}/skills/flutter-use-http-package/SKILL.md +0 -0
@@ -1,163 +0,0 @@
1
- ---
2
- name: flutter-add-integration-test
3
- description: Configures Flutter Driver for app interaction and converts MCP actions into permanent integration tests. Use when adding integration testing to a project, exploring UI components via MCP, or automating user flows with the integration_test package.
4
- metadata:
5
- model: models/gemini-3.1-pro-preview
6
- last_modified: Tue, 21 Apr 2026 18:29:20 GMT
7
- ---
8
- # Implementing Flutter Integration Tests
9
-
10
- ## Contents
11
- - [Project Setup and Dependencies](#project-setup-and-dependencies)
12
- - [Interactive Exploration via MCP](#interactive-exploration-via-mcp)
13
- - [Test Authoring Guidelines](#test-authoring-guidelines)
14
- - [Execution and Profiling](#execution-and-profiling)
15
- - [Workflow: End-to-End Integration Testing](#workflow-end-to-end-integration-testing)
16
- - [Examples](#examples)
17
-
18
- ## Project Setup and Dependencies
19
-
20
- Configure the project to support integration testing and Flutter Driver extensions.
21
-
22
- 1. Add required development dependencies to `pubspec.yaml`:
23
- ```bash
24
- flutter pub add 'dev:integration_test:{"sdk":"flutter"}'
25
- flutter pub add 'dev:flutter_test:{"sdk":"flutter"}'
26
- ```
27
- 2. Enable the Flutter Driver extension in your application entry point (typically `lib/main.dart` or a dedicated `lib/main_test.dart`):
28
- - Import `package:flutter_driver/driver_extension.dart`.
29
- - Call `enableFlutterDriverExtension();` before `runApp()`.
30
- 3. Add `Key` parameters (e.g., `ValueKey('login_button')`) to critical widgets in the application code to ensure reliable targeting during tests.
31
-
32
- ## Interactive Exploration via MCP
33
-
34
- Use the Dart/Flutter MCP server tools to interactively explore and manipulate the application state before writing static tests.
35
-
36
- - **Launch**: Execute `launch_app` with `target: "lib/main_test.dart"` to start the application and acquire the DTD URI.
37
- - **Inspect**: Execute `get_widget_tree` to discover available `Key`s, `Text` nodes, and widget `Type`s.
38
- - **Interact**: Execute `tap`, `enter_text`, and `scroll` to simulate user flows.
39
- - **Wait**: Always execute `waitFor` or verify state with `get_health` when navigating or triggering animations.
40
- - **Troubleshoot Unmounted Widgets**: If a widget is not found in the tree, it may be lazily loaded in a `SliverList` or `ListView`. Execute `scroll` or `scrollIntoView` to force the widget to mount before interacting with it.
41
-
42
- ## Test Authoring Guidelines
43
-
44
- Structure integration tests using the `flutter_test` API paradigm.
45
-
46
- - Create a dedicated `integration_test/` directory at the project root.
47
- - Name all test files using the `<name>_test.dart` convention.
48
- - Initialize the binding by calling `IntegrationTestWidgetsFlutterBinding.ensureInitialized();` at the start of `main()`.
49
- - Load the application UI using `await tester.pumpWidget(MyApp());`.
50
- - Trigger frames and wait for animations to complete using `await tester.pumpAndSettle();` after interactions like `tester.tap()`.
51
- - Assert widget visibility using `expect(find.byKey(ValueKey('foo')), findsOneWidget);` or `findsNothing`.
52
- - Scroll to specific off-screen widgets using `await tester.scrollUntilVisible(itemFinder, 500.0, scrollable: listFinder);`.
53
-
54
- **Conditional Logic for Legacy `flutter_driver`:**
55
- - If maintaining or migrating legacy `flutter_driver` tests, use `driver.waitFor()`, `driver.waitForAbsent()`, `driver.tap()`, and `driver.scroll()` instead of the `WidgetTester` APIs.
56
-
57
- ## Execution and Profiling
58
-
59
- Execute tests using the `flutter drive` command. Require a host driver script located in `test_driver/integration_test.dart` that calls `integrationDriver()`.
60
-
61
- **Conditional Execution Targets:**
62
- - **If testing on Chrome:** Launch `chromedriver --port=4444` in a separate terminal, then run:
63
- `flutter drive --driver=test_driver/integration_test.dart --target=integration_test/app_test.dart -d chrome`
64
- - **If testing headless web:** Run with `-d web-server`.
65
- - **If testing on Android (Local):** Run `flutter drive --driver=test_driver/integration_test.dart --target=integration_test/app_test.dart`.
66
- - **If testing on Firebase Test Lab (Android):**
67
- 1. Build debug APK: `flutter build apk --debug`
68
- 2. Build test APK: `./gradlew app:assembleAndroidTest`
69
- 3. Upload both APKs to the Firebase Test Lab console.
70
-
71
- ## Workflow: End-to-End Integration Testing
72
-
73
- Copy and follow this checklist to implement and verify integration tests.
74
-
75
- - [ ] **Task Progress: Setup**
76
- - [ ] Add `integration_test` and `flutter_test` to `pubspec.yaml`.
77
- - [ ] Inject `enableFlutterDriverExtension()` into the app entry point.
78
- - [ ] Assign `ValueKey`s to target widgets.
79
- - [ ] **Task Progress: Exploration**
80
- - [ ] Run `launch_app` via MCP.
81
- - [ ] Map the widget tree using `get_widget_tree`.
82
- - [ ] Validate interaction paths using MCP tools (`tap`, `enter_text`).
83
- - [ ] **Task Progress: Authoring**
84
- - [ ] Create `integration_test/app_test.dart`.
85
- - [ ] Write test cases using `WidgetTester` APIs.
86
- - [ ] Create `test_driver/integration_test.dart` with `integrationDriver()`.
87
- - [ ] **Task Progress: Execution & Feedback Loop**
88
- - [ ] Run `flutter drive --driver=test_driver/integration_test.dart --target=integration_test/app_test.dart`.
89
- - [ ] **Feedback Loop**: Review test output -> If `PumpAndSettleTimedOutException` occurs, check for infinite animations -> If widget not found, add `scrollUntilVisible` -> Re-run test until passing.
90
-
91
- ## Examples
92
-
93
- ### Standard Integration Test (`integration_test/app_test.dart`)
94
-
95
- ```dart
96
- import 'package:flutter/material.dart';
97
- import 'package:flutter_test/flutter_test.dart';
98
- import 'package:integration_test/integration_test.dart';
99
- import 'package:my_app/main.dart';
100
-
101
- void main() {
102
- IntegrationTestWidgetsFlutterBinding.ensureInitialized();
103
-
104
- group('End-to-end test', () {
105
- testWidgets('tap on the floating action button, verify counter', (tester) async {
106
- // Load app widget.
107
- await tester.pumpWidget(const MyApp());
108
-
109
- // Verify the counter starts at 0.
110
- expect(find.text('0'), findsOneWidget);
111
-
112
- // Find the floating action button to tap on.
113
- final fab = find.byKey(const ValueKey('increment'));
114
-
115
- // Emulate a tap on the floating action button.
116
- await tester.tap(fab);
117
-
118
- // Trigger a frame and wait for animations.
119
- await tester.pumpAndSettle();
120
-
121
- // Verify the counter increments by 1.
122
- expect(find.text('1'), findsOneWidget);
123
- });
124
- });
125
- }
126
- ```
127
-
128
- ### Host Driver Script (`test_driver/integration_test.dart`)
129
-
130
- ```dart
131
- import 'package:integration_test/integration_test_driver.dart';
132
-
133
- Future<void> main() => integrationDriver();
134
- ```
135
-
136
- ### Performance Profiling Driver Script (`test_driver/perf_driver.dart`)
137
-
138
- Use this driver script if you wrap your test actions in `binding.traceAction()` to capture performance metrics.
139
-
140
- ```dart
141
- import 'package:flutter_driver/flutter_driver.dart' as driver;
142
- import 'package:integration_test/integration_test_driver.dart';
143
-
144
- Future<void> main() {
145
- return integrationDriver(
146
- responseDataCallback: (data) async {
147
- if (data != null) {
148
- final timeline = driver.Timeline.fromJson(
149
- data['scrolling_timeline'] as Map<String, dynamic>,
150
- );
151
-
152
- final summary = driver.TimelineSummary.summarize(timeline);
153
-
154
- await summary.writeTimelineToFile(
155
- 'scrolling_timeline',
156
- pretty: true,
157
- includeSummary: true,
158
- );
159
- }
160
- },
161
- );
162
- }
163
- ```
@@ -1,145 +0,0 @@
1
- ---
2
- name: flutter-add-widget-preview
3
- description: Adds interactive widget previews to the project using the previews.dart system. Use when creating new UI components or updating existing screens to ensure consistent design and interactive testing.
4
- metadata:
5
- model: models/gemini-3.1-pro-preview
6
- last_modified: Tue, 21 Apr 2026 20:05:23 GMT
7
- ---
8
- # Previewing Flutter Widgets
9
-
10
- ## Contents
11
- - [Preview Guidelines](#preview-guidelines)
12
- - [Handling Limitations](#handling-limitations)
13
- - [Workflows](#workflows)
14
- - [Examples](#examples)
15
-
16
- ## Preview Guidelines
17
-
18
- Use the Flutter Widget Previewer to render widgets in real-time, isolated from the full application context.
19
-
20
- - **Target Elements:** Apply the `@Preview` annotation to top-level functions, static methods within a class, or public widget constructors/factories that have no required arguments and return a `Widget` or `WidgetBuilder`.
21
- - **Imports:** Always import `package:flutter/widget_previews.dart` to access the preview annotations.
22
- - **Custom Annotations:** Extend the `Preview` class to create custom annotations that inject common properties (e.g., themes, wrappers) across multiple widgets.
23
- - **Multiple Configurations:** Apply multiple `@Preview` annotations to a single target to generate multiple preview instances. Alternatively, extend `MultiPreview` to encapsulate common multi-preview configurations.
24
- - **Runtime Transformations:** Override the `transform()` method in custom `Preview` or `MultiPreview` classes to modify preview configurations dynamically at runtime (e.g., generating names based on dynamic values, which is impossible in a `const` context).
25
-
26
- ## Handling Limitations
27
-
28
- Adhere to the following constraints when authoring previewable widgets, as the Widget Previewer runs in a web environment:
29
-
30
- - **No Native APIs:** Do not use native plugins or APIs from `dart:io` or `dart:ffi`. Widgets with transitive dependencies on `dart:io` or `dart:ffi` will throw exceptions upon invocation. Use conditional imports to mock or bypass these in preview mode.
31
- - **Asset Paths:** Use package-based paths for assets loaded via `dart:ui` `fromAsset` APIs (e.g., `packages/my_package_name/assets/my_image.png` instead of `assets/my_image.png`).
32
- - **Public Callbacks:** Ensure all callback arguments provided to preview annotations are public and constant to satisfy code generation requirements.
33
- - **Constraints:** Apply explicit constraints using the `size` parameter in the `@Preview` annotation if your widget is unconstrained, as the previewer defaults to constraining them to approximately half the viewport.
34
-
35
- ## Workflows
36
-
37
- ### Creating a Widget Preview
38
- Copy and track this checklist when implementing a new widget preview:
39
-
40
- - [ ] Import `package:flutter/widget_previews.dart`.
41
- - [ ] Identify a valid target (top-level function, static method, or parameter-less public constructor).
42
- - [ ] Apply the `@Preview` annotation to the target.
43
- - [ ] Configure preview parameters (`name`, `group`, `size`, `theme`, `brightness`, etc.) as needed.
44
- - [ ] If applying the same configuration to multiple widgets, extract the configuration into a custom class extending `Preview`.
45
-
46
- ### Interacting with Previews
47
- Follow the appropriate conditional workflow to launch and interact with the Widget Previewer:
48
-
49
- **If using a supported IDE (Android Studio, IntelliJ, VS Code with Flutter 3.38+):**
50
- 1. Launch the IDE. The Widget Previewer starts automatically.
51
- 2. Open the "Flutter Widget Preview" tab in the sidebar.
52
- 3. Toggle "Filter previews by selected file" at the bottom left if you want to view previews outside the currently active file.
53
-
54
- **If using the Command Line:**
55
- 1. Navigate to the Flutter project's root directory.
56
- 2. Run `flutter widget-preview start`.
57
- 3. View the automatically opened Chrome environment.
58
-
59
- **Feedback Loop: Preview Iteration**
60
- 1. Modify the widget code or preview configuration.
61
- 2. Observe the automatic update in the Widget Previewer.
62
- 3. If global state (e.g., static initializers) was modified: Click the global hot restart button at the bottom right.
63
- 4. If only the local widget state needs resetting: Click the individual hot restart button on the specific preview card.
64
- 5. Review errors in the IDE/CLI console -> fix -> repeat.
65
-
66
- ## Examples
67
-
68
- ### Basic Preview
69
- ```dart
70
- import 'package:flutter/widget_previews.dart';
71
- import 'package:flutter/material.dart';
72
-
73
- @Preview(name: 'My Sample Text', group: 'Typography')
74
- Widget mySampleText() {
75
- return const Text('Hello, World!');
76
- }
77
- ```
78
-
79
- ### Custom Preview with Runtime Transformation
80
- ```dart
81
- import 'package:flutter/widget_previews.dart';
82
- import 'package:flutter/material.dart';
83
-
84
- final class TransformativePreview extends Preview {
85
- const TransformativePreview({
86
- super.name,
87
- super.group,
88
- });
89
-
90
- PreviewThemeData _themeBuilder() {
91
- return PreviewThemeData(
92
- materialLight: ThemeData.light(),
93
- materialDark: ThemeData.dark(),
94
- );
95
- }
96
-
97
- @override
98
- Preview transform() {
99
- final originalPreview = super.transform();
100
- final builder = originalPreview.toBuilder();
101
-
102
- builder
103
- ..name = 'Transformed - ${originalPreview.name}'
104
- ..theme = _themeBuilder;
105
-
106
- return builder.toPreview();
107
- }
108
- }
109
-
110
- @TransformativePreview(name: 'Custom Themed Button')
111
- Widget myButton() => const ElevatedButton(onPressed: null, child: Text('Click'));
112
- ```
113
-
114
- ### MultiPreview Implementation
115
- ```dart
116
- import 'package:flutter/widget_previews.dart';
117
- import 'package:flutter/material.dart';
118
-
119
- /// Creates light and dark mode previews automatically.
120
- final class MultiBrightnessPreview extends MultiPreview {
121
- const MultiBrightnessPreview({required this.name});
122
-
123
- final String name;
124
-
125
- @override
126
- List<Preview> get previews => const [
127
- Preview(brightness: Brightness.light),
128
- Preview(brightness: Brightness.dark),
129
- ];
130
-
131
- @override
132
- List<Preview> transform() {
133
- final previews = super.transform();
134
- return previews.map((preview) {
135
- final builder = preview.toBuilder()
136
- ..group = 'Brightness'
137
- ..name = '$name - ${preview.brightness!.name}';
138
- return builder.toPreview();
139
- }).toList();
140
- }
141
- }
142
-
143
- @MultiBrightnessPreview(name: 'Primary Card')
144
- Widget cardPreview() => const Card(child: Padding(padding: EdgeInsets.all(8.0), child: Text('Content')));
145
- ```
@@ -1,154 +0,0 @@
1
- ---
2
- name: flutter-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
- metadata:
5
- model: models/gemini-3.1-pro-preview
6
- last_modified: Tue, 21 Apr 2026 21:15:41 GMT
7
- ---
8
- # Writing Flutter Widget Tests
9
-
10
- ## Contents
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
- - [ ] **Step 1: Define the test.** Use `testWidgets('description', (WidgetTester tester) async { ... })`.
39
- - [ ] **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.
40
- - [ ] **Step 3: Locate elements.** Instantiate `Finder` objects for the target widgets.
41
- - [ ] **Step 4: Verify initial state.** Use `expect(finder, matcher)` to validate the initial render.
42
- - [ ] **Step 5: Simulate interactions.** Execute gestures or inputs (e.g., `await tester.tap(buttonFinder)`).
43
- - [ ] **Step 6: Rebuild the tree.** Call `await tester.pump()` or `await tester.pumpAndSettle()` to process state changes.
44
- - [ ] **Step 7: Verify updated state.** Use `expect()` to validate the UI after the interaction.
45
- - [ ] **Step 8: Run and validate.** Execute `flutter test test/your_test_file_test.dart`.
46
- - [ ] **Step 9: Feedback Loop.** Review test output -> identify failing matchers -> adjust widget logic or test assertions -> re-run until passing.
47
-
48
- ## Interaction & State Management
49
-
50
- Apply the following conditional logic based on the type of interaction or state change being tested:
51
-
52
- * **If testing static rendering:** Call `await tester.pumpWidget()` once, then immediately run `expect()` assertions.
53
- * **If testing standard state changes (e.g., button taps):**
54
- 1. Call `await tester.tap(finder)`.
55
- 2. Call `await tester.pump()` to trigger a single frame rebuild.
56
- * **If testing animations, transitions, or asynchronous UI updates:**
57
- 1. Trigger the action (e.g., `await tester.drag(finder, Offset(500, 0))`).
58
- 2. Call `await tester.pumpAndSettle()` to repeatedly pump frames until no more frames are scheduled (animation completes).
59
- * **If testing text input:** Call `await tester.enterText(textFieldFinder, 'Input string')`.
60
- * **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.
61
-
62
- ## Examples
63
-
64
- ### High-Fidelity Widget Test Implementation
65
-
66
- **Target Widget (`lib/todo_list.dart`):**
67
- ```dart
68
- import 'package:flutter/material.dart';
69
-
70
- class TodoList extends StatefulWidget {
71
- const TodoList({super.key});
72
-
73
- @override
74
- State<TodoList> createState() => _TodoListState();
75
- }
76
-
77
- class _TodoListState extends State<TodoList> {
78
- final todos = <String>[];
79
- final controller = TextEditingController();
80
-
81
- @override
82
- Widget build(BuildContext context) {
83
- return MaterialApp(
84
- home: Scaffold(
85
- body: Column(
86
- children: [
87
- TextField(controller: controller),
88
- Expanded(
89
- child: ListView.builder(
90
- itemCount: todos.length,
91
- itemBuilder: (context, index) {
92
- final todo = todos[index];
93
- return Dismissible(
94
- key: Key('$todo$index'),
95
- onDismissed: (_) => setState(() => todos.removeAt(index)),
96
- child: ListTile(title: Text(todo)),
97
- );
98
- },
99
- ),
100
- ),
101
- ],
102
- ),
103
- floatingActionButton: FloatingActionButton(
104
- onPressed: () {
105
- setState(() {
106
- todos.add(controller.text);
107
- controller.clear();
108
- });
109
- },
110
- child: const Icon(Icons.add),
111
- ),
112
- ),
113
- );
114
- }
115
- }
116
- ```
117
-
118
- **Test Implementation (`test/todo_list_test.dart`):**
119
- ```dart
120
- import 'package:flutter/material.dart';
121
- import 'package:flutter_test/flutter_test.dart';
122
- import 'package:my_app/todo_list.dart';
123
-
124
- void main() {
125
- testWidgets('Add and remove a todo item', (WidgetTester tester) async {
126
- // 1. Build the widget
127
- await tester.pumpWidget(const TodoList());
128
-
129
- // 2. Verify initial state
130
- expect(find.byType(ListTile), findsNothing);
131
-
132
- // 3. Enter text into the TextField
133
- await tester.enterText(find.byType(TextField), 'Buy groceries');
134
-
135
- // 4. Tap the add button
136
- await tester.tap(find.byType(FloatingActionButton));
137
-
138
- // 5. Rebuild the widget to reflect the new state
139
- await tester.pump();
140
-
141
- // 6. Verify the item was added
142
- expect(find.text('Buy groceries'), findsOneWidget);
143
-
144
- // 7. Swipe the item to dismiss it
145
- await tester.drag(find.byType(Dismissible), const Offset(500, 0));
146
-
147
- // 8. Build the widget until the dismiss animation ends
148
- await tester.pumpAndSettle();
149
-
150
- // 9. Verify the item was removed
151
- expect(find.text('Buy groceries'), findsNothing);
152
- });
153
- }
154
- ```
@@ -1,162 +0,0 @@
1
- ---
2
- name: flutter-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
- metadata:
5
- model: models/gemini-3.1-pro-preview
6
- last_modified: Tue, 21 Apr 2026 20:11:20 GMT
7
- ---
8
- # Architecting Flutter Applications
9
-
10
- ## Contents
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
- Implement the MVVM (Model-View-ViewModel) pattern to manage UI state and logic.
22
- * **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.
23
- * **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.
24
-
25
- ### Data Layer
26
- Implement the Repository pattern to isolate data access logic and create a single source of truth.
27
- * **Services:** Create stateless classes to wrap external APIs (HTTP clients, local databases, platform plugins). Return raw API models or `Result` wrappers.
28
- * **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.
29
-
30
- ### Logic Layer (Domain - Optional)
31
- * **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.
32
-
33
- ## Project Structure
34
-
35
- Organize the codebase using a hybrid approach: group UI components by feature, and group Data/Domain components by type.
36
-
37
- ```text
38
- lib/
39
- ├── data/
40
- │ ├── models/ # API models
41
- │ ├── repositories/ # Repository implementations
42
- │ └── services/ # API clients, local storage wrappers
43
- ├── domain/
44
- │ ├── models/ # Clean domain models
45
- │ └── use_cases/ # Optional business logic classes
46
- └── ui/
47
- ├── core/ # Shared widgets, themes, typography
48
- └── features/
49
- └── [feature_name]/
50
- ├── view_models/
51
- └── views/
52
- ```
53
-
54
- ## Workflow: Implementing a New Feature
55
-
56
- Follow this sequential workflow when adding a new feature to the application. Copy the checklist to track progress.
57
-
58
- ### Task Progress
59
- - [ ] **Step 1: Define Domain Models.** Create immutable data classes for the feature using `freezed` or `built_value`.
60
- - [ ] **Step 2: Implement Services.** Create or update Service classes to handle external API communication.
61
- - [ ] **Step 3: Implement Repositories.** Create the Repository to consume Services and return Domain Models.
62
- - [ ] **Step 4: Apply Conditional Logic (Domain Layer).**
63
- - *If the feature requires complex data transformation or cross-repository logic:* Create a Use Case class.
64
- - *If the feature is a simple CRUD operation:* Skip to Step 5.
65
- - [ ] **Step 5: Implement the ViewModel.** Create the ViewModel extending `ChangeNotifier`. Inject required Repositories/Use Cases. Expose immutable state and command methods.
66
- - [ ] **Step 6: Implement the View.** Create the UI widget. Use `ListenableBuilder` or `AnimatedBuilder` to listen to ViewModel changes.
67
- - [ ] **Step 7: Inject Dependencies.** Register the new Service, Repository, and ViewModel in the dependency injection container (e.g., `provider` or `get_it`).
68
- - [ ] **Step 8: Run Validator.** Execute unit tests for the ViewModel and Repository.
69
- - *Feedback Loop:* Run tests -> Review failures -> Fix logic -> Re-run until passing.
70
-
71
- ## Examples
72
-
73
- ### Data Layer: Service and Repository
74
-
75
- ```dart
76
- // 1. Service (Raw API interaction)
77
- class ApiClient {
78
- Future<UserApiModel> fetchUser(String id) async {
79
- // HTTP GET implementation...
80
- }
81
- }
82
-
83
- // 2. Repository (Single source of truth, returns Domain Model)
84
- class UserRepository {
85
- UserRepository({required ApiClient apiClient}) : _apiClient = apiClient;
86
-
87
- final ApiClient _apiClient;
88
- User? _cachedUser;
89
-
90
- Future<User> getUser(String id) async {
91
- if (_cachedUser != null) return _cachedUser!;
92
-
93
- final apiModel = await _apiClient.fetchUser(id);
94
- _cachedUser = User(id: apiModel.id, name: apiModel.fullName); // Transform to Domain Model
95
- return _cachedUser!;
96
- }
97
- }
98
- ```
99
-
100
- ### UI Layer: ViewModel and View
101
-
102
- ```dart
103
- // 3. ViewModel (State management and presentation logic)
104
- class ProfileViewModel extends ChangeNotifier {
105
- ProfileViewModel({required UserRepository userRepository})
106
- : _userRepository = userRepository;
107
-
108
- final UserRepository _userRepository;
109
-
110
- User? _user;
111
- User? get user => _user;
112
-
113
- bool _isLoading = false;
114
- bool get isLoading => _isLoading;
115
-
116
- Future<void> loadProfile(String id) async {
117
- _isLoading = true;
118
- notifyListeners();
119
-
120
- try {
121
- _user = await _userRepository.getUser(id);
122
- } finally {
123
- _isLoading = false;
124
- notifyListeners();
125
- }
126
- }
127
- }
128
-
129
- // 4. View (Dumb UI component)
130
- class ProfileView extends StatelessWidget {
131
- const ProfileView({super.key, required this.viewModel});
132
-
133
- final ProfileViewModel viewModel;
134
-
135
- @override
136
- Widget build(BuildContext context) {
137
- return ListenableBuilder(
138
- listenable: viewModel,
139
- builder: (context, _) {
140
- if (viewModel.isLoading) {
141
- return const Center(child: CircularProgressIndicator());
142
- }
143
-
144
- final user = viewModel.user;
145
- if (user == null) {
146
- return const Center(child: Text('User not found'));
147
- }
148
-
149
- return Column(
150
- children: [
151
- Text(user.name),
152
- ElevatedButton(
153
- onPressed: () => viewModel.loadProfile(user.id),
154
- child: const Text('Refresh'),
155
- ),
156
- ],
157
- );
158
- },
159
- );
160
- }
161
- }
162
- ```