sdd-full 4.6.2 → 4.8.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.
Files changed (173) hide show
  1. package/bin.js +1 -1
  2. package/package.json +1 -1
  3. package/skills/.agents/skills/flutter-add-integration-test/SKILL.md +165 -0
  4. package/skills/.agents/skills/flutter-add-widget-preview/SKILL.md +147 -0
  5. package/skills/.agents/skills/flutter-add-widget-test/SKILL.md +156 -0
  6. package/skills/.agents/skills/flutter-apply-architecture-best-practices/SKILL.md +164 -0
  7. package/skills/.agents/skills/flutter-build-responsive-layout/SKILL.md +141 -0
  8. package/skills/.agents/skills/flutter-fix-layout-issues/SKILL.md +132 -0
  9. package/skills/.agents/skills/flutter-implement-json-serialization/SKILL.md +155 -0
  10. package/skills/.agents/skills/flutter-setup-declarative-routing/SKILL.md +257 -0
  11. package/skills/.agents/skills/flutter-setup-localization/SKILL.md +212 -0
  12. package/skills/.agents/skills/flutter-use-http-package/SKILL.md +177 -0
  13. package/skills/VERSION.md +176 -62
  14. package/skills/design-planning/ai-coding-rules/SKILL.md +5 -13
  15. package/skills/design-planning/design-to-code/SKILL.md +5 -14
  16. package/skills/design-planning/enterprise-spec/SKILL.md +5 -13
  17. package/skills/design-planning/flutter-av/SKILL.md +5 -16
  18. package/skills/design-planning/flutter-map/SKILL.md +5 -14
  19. package/skills/design-planning/function-sdd/SKILL.md +5 -13
  20. package/skills/design-planning/global-overlay-stack-standard/SKILL.md +73 -0
  21. package/skills/design-planning/ui-motion-interaction-standard/SKILL.md +69 -0
  22. package/skills/design-planning/ui-sdd-specialized/SKILL.md +5 -14
  23. package/skills/development-execution/flutter-errors/SKILL.md +5 -15
  24. package/skills/flutter-skills/.github/dependabot.yaml +15 -0
  25. package/skills/flutter-skills/.github/workflows/dart_skills_lint_workflow.yaml +68 -0
  26. package/skills/flutter-skills/.github/workflows/skills_tool.yaml +51 -0
  27. package/skills/flutter-skills/CODE_OF_CONDUCT.md +3 -0
  28. package/skills/flutter-skills/CONTRIBUTING.md +36 -0
  29. package/skills/flutter-skills/LICENSE +26 -0
  30. package/skills/flutter-skills/README.md +50 -0
  31. package/skills/flutter-skills/pubspec.yaml +9 -0
  32. package/skills/flutter-skills/resources/flutter_skills.yaml +434 -0
  33. package/skills/flutter-skills/skills/flutter-add-integration-test/SKILL.md +163 -0
  34. package/skills/flutter-skills/skills/flutter-add-widget-preview/SKILL.md +145 -0
  35. package/skills/flutter-skills/skills/flutter-add-widget-test/SKILL.md +154 -0
  36. package/skills/flutter-skills/skills/flutter-apply-architecture-best-practices/SKILL.md +162 -0
  37. package/skills/flutter-skills/skills/flutter-build-responsive-layout/SKILL.md +139 -0
  38. package/skills/flutter-skills/skills/flutter-fix-layout-issues/SKILL.md +130 -0
  39. package/skills/flutter-skills/skills/flutter-implement-json-serialization/SKILL.md +153 -0
  40. package/skills/flutter-skills/skills/flutter-setup-declarative-routing/SKILL.md +255 -0
  41. package/skills/flutter-skills/skills/flutter-setup-localization/SKILL.md +210 -0
  42. package/skills/flutter-skills/skills/flutter-use-http-package/SKILL.md +175 -0
  43. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/add-dart-lint-validation-rule/SKILL.md +196 -0
  44. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-best-practices/SKILL.md +65 -0
  45. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-checks-migration/SKILL.md +158 -0
  46. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-cli-app-best-practices/SKILL.md +168 -0
  47. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-doc-validation/SKILL.md +87 -0
  48. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-long-lines/SKILL.md +101 -0
  49. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-matcher-best-practices/SKILL.md +136 -0
  50. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-modern-features/SKILL.md +266 -0
  51. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-package-maintenance/SKILL.md +92 -0
  52. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-test-coverage/SKILL.md +92 -0
  53. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-test-coverage/example/lib/src/calculator.dart +7 -0
  54. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-test-coverage/example/pubspec.yaml +8 -0
  55. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-test-coverage/example/test/calculator_test.dart +11 -0
  56. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-test-coverage/scripts/interpret_coverage.dart +95 -0
  57. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-test-coverage/scripts/pubspec.yaml +6 -0
  58. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-test-coverage/scripts/test/interpret_coverage_test.dart +93 -0
  59. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-test-fundamentals/SKILL.md +173 -0
  60. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/definition-of-done/SKILL.md +27 -0
  61. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/flutter_skills_ignore.json +3 -0
  62. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/grill-me/SKILL.md +10 -0
  63. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/ignore.json +3 -0
  64. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/test-driven-development/SKILL.md +371 -0
  65. package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/test-driven-development/testing-anti-patterns.md +299 -0
  66. package/skills/flutter-skills/tool/dart_skills_lint/AUTHORS +7 -0
  67. package/skills/flutter-skills/tool/dart_skills_lint/CHANGELOG.md +12 -0
  68. package/skills/flutter-skills/tool/dart_skills_lint/CONTRIBUTING.md +51 -0
  69. package/skills/flutter-skills/tool/dart_skills_lint/LICENSE +27 -0
  70. package/skills/flutter-skills/tool/dart_skills_lint/README.md +203 -0
  71. package/skills/flutter-skills/tool/dart_skills_lint/analysis_options.yaml +296 -0
  72. package/skills/flutter-skills/tool/dart_skills_lint/bench/README.md +23 -0
  73. package/skills/flutter-skills/tool/dart_skills_lint/bench/baseline_throughput.dart +230 -0
  74. package/skills/flutter-skills/tool/dart_skills_lint/bin/cli.dart +10 -0
  75. package/skills/flutter-skills/tool/dart_skills_lint/dart_skills_lint.yaml +14 -0
  76. package/skills/flutter-skills/tool/dart_skills_lint/documentation/feature_design_docs/PRODUCTION_READYNESS.md +48 -0
  77. package/skills/flutter-skills/tool/dart_skills_lint/documentation/feature_design_docs/completion_migration_plan.md +99 -0
  78. package/skills/flutter-skills/tool/dart_skills_lint/documentation/feature_design_docs/legacy_patterns_report.md +110 -0
  79. package/skills/flutter-skills/tool/dart_skills_lint/documentation/feature_design_docs/pub_vs_skill_report.md +56 -0
  80. package/skills/flutter-skills/tool/dart_skills_lint/documentation/knowledge/SPECIFICATION.md +79 -0
  81. package/skills/flutter-skills/tool/dart_skills_lint/documentation/knowledge/architecture_overview.md +64 -0
  82. package/skills/flutter-skills/tool/dart_skills_lint/lib/dart_skills_lint.dart +11 -0
  83. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/config_parser.dart +156 -0
  84. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/entry_point.dart +354 -0
  85. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/fixable_rule.dart +20 -0
  86. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/models/analysis_severity.dart +15 -0
  87. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/models/check_type.dart +17 -0
  88. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/models/ignore_entry.dart +34 -0
  89. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/models/ignore_entry.g.dart +19 -0
  90. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/models/skill_context.dart +27 -0
  91. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/models/skill_rule.dart +27 -0
  92. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/models/skills_ignores.dart +26 -0
  93. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/models/skills_ignores.g.dart +24 -0
  94. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/models/validation_error.dart +31 -0
  95. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/rule_registry.dart +79 -0
  96. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/rules/absolute_paths_rule.dart +74 -0
  97. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/rules/description_length_rule.dart +49 -0
  98. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/rules/disallowed_field_rule.dart +61 -0
  99. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/rules/name_format_rule.dart +167 -0
  100. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/rules/relative_paths_rule.dart +72 -0
  101. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/rules/trailing_whitespace_rule.dart +93 -0
  102. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/rules/valid_yaml_metadata_rule.dart +74 -0
  103. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/skills_ignores_storage.dart +36 -0
  104. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/validation_session.dart +559 -0
  105. package/skills/flutter-skills/tool/dart_skills_lint/lib/src/validator.dart +238 -0
  106. package/skills/flutter-skills/tool/dart_skills_lint/pubspec.yaml +28 -0
  107. package/skills/flutter-skills/tool/dart_skills_lint/skills/README.md +10 -0
  108. package/skills/flutter-skills/tool/dart_skills_lint/skills/dart-skills-lint-validation/SKILL.md +195 -0
  109. package/skills/flutter-skills/tool/dart_skills_lint/skills-lock.json +75 -0
  110. package/skills/flutter-skills/tool/dart_skills_lint/test/absolute_paths_test.dart +167 -0
  111. package/skills/flutter-skills/tool/dart_skills_lint/test/cli_integration_test.dart +683 -0
  112. package/skills/flutter-skills/tool/dart_skills_lint/test/config_file_test.dart +292 -0
  113. package/skills/flutter-skills/tool/dart_skills_lint/test/custom_rule_test.dart +122 -0
  114. package/skills/flutter-skills/tool/dart_skills_lint/test/directory_structure_test.dart +163 -0
  115. package/skills/flutter-skills/tool/dart_skills_lint/test/field_constraints_test.dart +178 -0
  116. package/skills/flutter-skills/tool/dart_skills_lint/test/fixer_test.dart +172 -0
  117. package/skills/flutter-skills/tool/dart_skills_lint/test/ignore_models_test.dart +63 -0
  118. package/skills/flutter-skills/tool/dart_skills_lint/test/metadata_validation_test.dart +116 -0
  119. package/skills/flutter-skills/tool/dart_skills_lint/test/relative_path_flag_test.dart +70 -0
  120. package/skills/flutter-skills/tool/dart_skills_lint/test/relative_paths_test.dart +172 -0
  121. package/skills/flutter-skills/tool/dart_skills_lint/test/resolve_rules_test.dart +82 -0
  122. package/skills/flutter-skills/tool/dart_skills_lint/test/rule_naming_test.dart +29 -0
  123. package/skills/flutter-skills/tool/dart_skills_lint/test/skills_ignores_storage_test.dart +89 -0
  124. package/skills/flutter-skills/tool/dart_skills_lint/test/test_utils.dart +19 -0
  125. package/skills/flutter-skills/tool/dart_skills_lint/test/trailing_whitespace_test.dart +152 -0
  126. package/skills/flutter-skills/tool/generator/README.md +150 -0
  127. package/skills/flutter-skills/tool/generator/analysis_options.yaml +143 -0
  128. package/skills/flutter-skills/tool/generator/bin/skills.dart +73 -0
  129. package/skills/flutter-skills/tool/generator/lib/src/commands/base_skill_command.dart +87 -0
  130. package/skills/flutter-skills/tool/generator/lib/src/commands/base_yaml_command.dart +83 -0
  131. package/skills/flutter-skills/tool/generator/lib/src/commands/generate_skill_command.dart +92 -0
  132. package/skills/flutter-skills/tool/generator/lib/src/commands/update_readme_command.dart +150 -0
  133. package/skills/flutter-skills/tool/generator/lib/src/commands/update_skill_command.dart +97 -0
  134. package/skills/flutter-skills/tool/generator/lib/src/commands/validate_skill_command.dart +284 -0
  135. package/skills/flutter-skills/tool/generator/lib/src/models/skill_params.dart +41 -0
  136. package/skills/flutter-skills/tool/generator/lib/src/services/gemini_service.dart +310 -0
  137. package/skills/flutter-skills/tool/generator/lib/src/services/markdown_converter.dart +226 -0
  138. package/skills/flutter-skills/tool/generator/lib/src/services/prompts.dart +72 -0
  139. package/skills/flutter-skills/tool/generator/lib/src/services/resource_fetcher_service.dart +84 -0
  140. package/skills/flutter-skills/tool/generator/lib/src/services/skill_instructions.dart +30 -0
  141. package/skills/flutter-skills/tool/generator/pubspec.yaml +32 -0
  142. package/skills/flutter-skills/tool/generator/test/commands/base_skill_command_test.dart +131 -0
  143. package/skills/flutter-skills/tool/generator/test/commands/validate_skills_input_test.dart +263 -0
  144. package/skills/flutter-skills/tool/generator/test/custom_skill_rules/last_modified_rule.dart +32 -0
  145. package/skills/flutter-skills/tool/generator/test/generate_skills_retry_test.dart +105 -0
  146. package/skills/flutter-skills/tool/generator/test/generate_skills_test.dart +519 -0
  147. package/skills/flutter-skills/tool/generator/test/lint_skills_test.dart +34 -0
  148. package/skills/flutter-skills/tool/generator/test/markdown_converter_test.dart +103 -0
  149. package/skills/flutter-skills/tool/generator/test/markdown_table_test.dart +131 -0
  150. package/skills/flutter-skills/tool/generator/test/models/skill_params_test.dart +37 -0
  151. package/skills/flutter-skills/tool/generator/test/services/gemini_service_test.dart +291 -0
  152. package/skills/flutter-skills/tool/generator/test/services/markdown_converter_test.dart +156 -0
  153. package/skills/flutter-skills/tool/generator/test/services/resource_fetcher_service_test.dart +188 -0
  154. package/skills/flutter-skills/tool/generator/test/update_skills_test.dart +241 -0
  155. package/skills/flutter-skills/tool/generator/test/validate_skills_test.dart +728 -0
  156. package/skills/quality-assurance/bdd-acceptance/SKILL.md +5 -14
  157. package/skills/quality-assurance/flutter-test/SKILL.md +5 -16
  158. package/skills/rules/project_rules.md +538 -127
  159. package/skills/special-tools/env-check/SKILL.md +5 -13
  160. package/skills/special-tools/ios-full-auto-debug/SKILL.md +5 -15
  161. package/skills/writing-skills/SKILL.md +654 -0
  162. package/skills/writing-skills/anthropic-best-practices.md +1149 -0
  163. package/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
  164. package/skills/writing-skills/graphviz-conventions.dot +172 -0
  165. package/skills/writing-skills/persuasion-principles.md +187 -0
  166. package/skills/writing-skills/render-graphs.js +168 -0
  167. package/skills/writing-skills/testing-skills-with-subagents.md +384 -0
  168. package/skills/checklist.md +0 -154
  169. package/skills/rules/user_rules.md +0 -263
  170. package/skills//345/256/214/346/225/264/345/274/200/345/217/221/346/265/201/347/250/213/346/211/213/345/206/214.md +0 -454
  171. package/skills//346/212/200/350/203/275/344/275/223/347/263/273/345/256/214/345/226/204/345/273/272/350/256/256.md +0 -308
  172. package/skills//346/212/200/350/203/275/344/275/277/347/224/250/346/214/207/345/215/227.md +0 -309
  173. package/skills//346/212/200/350/203/275/345/206/263/347/255/226/346/240/221.md +0 -338
@@ -0,0 +1,141 @@
1
+ 【claude code调用标识:flutter-build-responsive-layout】【trae调用标识:flutter-build-responsive-layout+Flutter开发】【流程场景:1.完整3阶段SDD流程、3.小型功能迭代】
2
+
3
+ ---
4
+ name: flutter-build-responsive-layout
5
+ description: Use `LayoutBuilder`, `MediaQuery`, or `Expanded/Flexible` to create a layout that adapts to different screen sizes. Use when you need the UI to look good on both mobile and tablet/desktop form factors.
6
+ metadata:
7
+ model: models/gemini-3.1-pro-preview
8
+ last_modified: Tue, 21 Apr 2026 20:17:40 GMT
9
+ ---
10
+ # Implementing Adaptive Layouts
11
+
12
+ ## Contents
13
+ - [Space Measurement Guidelines](#space-measurement-guidelines)
14
+ - [Widget Sizing and Constraints](#widget-sizing-and-constraints)
15
+ - [Device and Orientation Behaviors](#device-and-orientation-behaviors)
16
+ - [Workflow: Constructing an Adaptive Layout](#workflow-constructing-an-adaptive-layout)
17
+ - [Workflow: Optimizing for Large Screens](#workflow-optimizing-for-large-screens)
18
+ - [Examples](#examples)
19
+
20
+ ## Space Measurement Guidelines
21
+ Determine the available space accurately to ensure layouts adapt to the app window, not just the physical device.
22
+
23
+ * **Use `MediaQuery.sizeOf(context)`** to get the size of the entire app window.
24
+ * **Use `LayoutBuilder`** to make layout decisions based on the parent widget's allocated space. Evaluate `constraints.maxWidth` to determine the appropriate widget tree to return.
25
+ * **Do not use `MediaQuery.orientationOf` or `OrientationBuilder`** near the top of the widget tree to switch layouts. Device orientation does not accurately reflect the available app window space.
26
+ * **Do not check for hardware types** (e.g., "phone" vs. "tablet"). Flutter apps run in resizable windows, multi-window modes, and picture-in-picture. Base all layout decisions strictly on available window space.
27
+
28
+ ## Widget Sizing and Constraints
29
+ Understand and apply Flutter's core layout rule: **Constraints go down. Sizes go up. Parent sets position.**
30
+
31
+ * **Distribute Space:** Use `Expanded` and `Flexible` within `Row`, `Column`, or `Flex` widgets.
32
+ * Use `Expanded` to force a child to fill all remaining available space (equivalent to `Flexible` with `fit: FlexFit.tight` and a `flex` factor of 1.0).
33
+ * Use `Flexible` to allow a child to size itself up to a specific limit while still expanding/contracting. Use the `flex` factor to define the ratio of space consumption among siblings.
34
+ * **Constrain Width:** Prevent widgets from consuming all horizontal space on large screens. Wrap widgets like `GridView` or `ListView` in a `ConstrainedBox` or `Container` and define a `maxWidth` in the `BoxConstraints`.
35
+ * **Lazy Rendering:** Always use `ListView.builder` or `GridView.builder` when rendering lists with an unknown or large number of items.
36
+
37
+ ## Device and Orientation Behaviors
38
+ Ensure the app behaves correctly across all device form factors and input methods.
39
+
40
+ * **Do not lock screen orientation.** Locking orientation causes severe layout issues on foldable devices, often resulting in letterboxing (the app centered with black borders). Android large format tiers require both portrait and landscape support.
41
+ * **Fallback for Locked Orientation:** If business requirements strictly mandate a locked orientation, use the `Display API` to retrieve physical screen dimensions instead of `MediaQuery`. `MediaQuery` fails to receive the larger window size in compatibility modes.
42
+ * **Support Multiple Inputs:** Implement support for basic mice, trackpads, and keyboard shortcuts. Ensure touch targets are appropriately sized and keyboard navigation is accessible.
43
+
44
+ ## Workflow: Constructing an Adaptive Layout
45
+
46
+ Follow this workflow to implement a layout that adapts to the available `BoxConstraints`.
47
+
48
+ **Task Progress:**
49
+ - [ ] Identify the target widget that requires adaptive behavior.
50
+ - [ ] Wrap the widget tree in a `LayoutBuilder`.
51
+ - [ ] Extract the `constraints.maxWidth` from the builder callback.
52
+ - [ ] Define an adaptive breakpoint (e.g., `largeScreenMinWidth = 600`).
53
+ - [ ] **If `maxWidth > largeScreenMinWidth`:** Return a large-screen layout (e.g., a `Row` placing a navigation sidebar and content area side-by-side).
54
+ - [ ] **If `maxWidth <= largeScreenMinWidth`:** Return a small-screen layout (e.g., a `Column` or standard navigation-style approach).
55
+ - [ ] Run validator -> resize the application window -> review layout transitions -> fix overflow errors.
56
+
57
+ ## Workflow: Optimizing for Large Screens
58
+
59
+ Follow this workflow to prevent UI elements from stretching unnaturally on large displays.
60
+
61
+ **Task Progress:**
62
+ - [ ] Identify full-width components (e.g., `ListView`, text blocks, forms).
63
+ - [ ] **If optimizing a list:** Convert `ListView.builder` to `GridView.builder` using `SliverGridDelegateWithMaxCrossAxisExtent` to automatically adjust column counts based on window size.
64
+ - [ ] **If optimizing a form or text block:** Wrap the component in a `ConstrainedBox`.
65
+ - [ ] Apply `BoxConstraints(maxWidth: [optimal_width])` to the `ConstrainedBox`.
66
+ - [ ] Wrap the `ConstrainedBox` in a `Center` widget to keep the constrained content centered on large screens.
67
+ - [ ] Run validator -> test on desktop/tablet target -> review horizontal stretching -> adjust `maxWidth` or grid extents.
68
+
69
+ ## Examples
70
+
71
+ ### Adaptive Layout using LayoutBuilder
72
+ Demonstrates switching between a mobile and desktop layout based on available width.
73
+
74
+ ```dart
75
+ import 'package:flutter/material.dart';
76
+
77
+ const double largeScreenMinWidth = 600.0;
78
+
79
+ class AdaptiveLayout extends StatelessWidget {
80
+ const AdaptiveLayout({super.key});
81
+
82
+ @override
83
+ Widget build(BuildContext context) {
84
+ return LayoutBuilder(
85
+ builder: (context, constraints) {
86
+ if (constraints.maxWidth > largeScreenMinWidth) {
87
+ return _buildLargeScreenLayout();
88
+ } else {
89
+ return _buildSmallScreenLayout();
90
+ }
91
+ },
92
+ );
93
+ }
94
+
95
+ Widget _buildLargeScreenLayout() {
96
+ return Row(
97
+ children: [
98
+ const SizedBox(width: 250, child: Placeholder(color: Colors.blue)),
99
+ const VerticalDivider(width: 1),
100
+ Expanded(child: const Placeholder(color: Colors.green)),
101
+ ],
102
+ );
103
+ }
104
+
105
+ Widget _buildSmallScreenLayout() {
106
+ return const Placeholder(color: Colors.green);
107
+ }
108
+ }
109
+ ```
110
+
111
+ ### Constraining Width on Large Screens
112
+ Demonstrates preventing a widget from consuming all horizontal space.
113
+
114
+ ```dart
115
+ import 'package:flutter/material.dart';
116
+
117
+ class ConstrainedContent extends StatelessWidget {
118
+ const ConstrainedContent({super.key});
119
+
120
+ @override
121
+ Widget build(BuildContext context) {
122
+ return Scaffold(
123
+ body: Center(
124
+ child: ConstrainedBox(
125
+ constraints: const BoxConstraints(
126
+ maxWidth: 800.0, // Maximum width for readability
127
+ ),
128
+ child: ListView.builder(
129
+ itemCount: 50,
130
+ itemBuilder: (context, index) {
131
+ return ListTile(
132
+ title: Text('Item $index'),
133
+ );
134
+ },
135
+ ),
136
+ ),
137
+ ),
138
+ );
139
+ }
140
+ }
141
+ ```
@@ -0,0 +1,132 @@
1
+ 【claude code调用标识:flutter-fix-layout-issues】【trae调用标识:flutter-fix-layout-issues+Flutter开发】【流程场景:4.Bug处理】
2
+
3
+ ---
4
+ name: flutter-fix-layout-issues
5
+ description: Fixes Flutter layout errors (overflows, unbounded constraints) using Dart and Flutter MCP tools. Use when addressing "RenderFlex overflowed", "Vertical viewport was given unbounded height", or similar layout issues.
6
+ metadata:
7
+ model: models/gemini-3.1-pro-preview
8
+ last_modified: Tue, 21 Apr 2026 19:45:59 GMT
9
+ ---
10
+ # Resolving Flutter Layout Errors
11
+
12
+ ## Contents
13
+ - [Constraint Violation Diagnostics](#constraint-violation-diagnostics)
14
+ - [Layout Error Resolution Workflow](#layout-error-resolution-workflow)
15
+ - [Examples](#examples)
16
+
17
+ ## Constraint Violation Diagnostics
18
+
19
+ Flutter layout operates on a strict rule: **Constraints go down. Sizes go up. Parent sets position.** Layout errors occur when this negotiation fails, typically due to unbounded constraints or unconstrained children.
20
+
21
+ Diagnose layout failures using the following error signatures:
22
+
23
+ * **"Vertical viewport was given unbounded height"**: Triggered when a scrollable widget (`ListView`, `GridView`) is placed inside an unconstrained vertical parent (`Column`). The parent provides infinite height, and the child attempts to expand infinitely.
24
+ * **"An InputDecorator...cannot have an unbounded width"**: Triggered when a `TextField` or `TextFormField` is placed inside an unconstrained horizontal parent (`Row`). The text field attempts to determine its width based on infinite available space.
25
+ * **"RenderFlex overflowed"**: Triggered when a child of a `Row` or `Column` requests a size larger than the parent's allocated constraints. Visually indicated by yellow and black warning stripes.
26
+ * **"Incorrect use of ParentData widget"**: Triggered when a `ParentDataWidget` is not a direct descendant of its required ancestor. (e.g., `Expanded` outside a `Flex`, `Positioned` outside a `Stack`).
27
+ * **"RenderBox was not laid out"**: A cascading side-effect error. Ignore this and look further up the stack trace for the primary constraint violation (usually an unbounded height/width error).
28
+
29
+ ## Layout Error Resolution Workflow
30
+
31
+ Copy and use this checklist to systematically resolve layout constraint violations.
32
+
33
+ ### Task Progress
34
+ - [ ] Run the application in debug mode to capture the exact layout exception in the console.
35
+ - [ ] Identify the primary error message (ignore cascading "RenderBox was not laid out" errors).
36
+ - [ ] Apply the conditional fix based on the specific error type:
37
+ - **If "Vertical viewport was given unbounded height"**: Wrap the scrollable child (`ListView`, `GridView`) in an `Expanded` widget to consume remaining space, or wrap it in a `SizedBox` to provide an absolute height constraint.
38
+ - **If "An InputDecorator...cannot have an unbounded width"**: Wrap the `TextField` or `TextFormField` in an `Expanded` or `Flexible` widget.
39
+ - **If "RenderFlex overflowed"**: Constrain the overflowing child by wrapping it in an `Expanded` widget (to force it to fit) or a `Flexible` widget (to allow it to be smaller than the allocated space).
40
+ - **If "Incorrect use of ParentData widget"**: Move the `ParentDataWidget` to be a direct child of its required parent. Ensure `Expanded`/`Flexible` are direct children of `Row`/`Column`/`Flex`. Ensure `Positioned` is a direct child of `Stack`.
41
+ - [ ] Execute Flutter hot reload.
42
+ - [ ] Run validator -> review errors -> fix: Inspect the UI to verify the red/grey error screen or yellow/black overflow stripes are resolved. If new layout errors appear, repeat the workflow.
43
+
44
+ ## Examples
45
+
46
+ ### Fixing Unbounded Height (ListView in Column)
47
+
48
+ **Input (Error State):**
49
+ ```dart
50
+ // Throws "Vertical viewport was given unbounded height"
51
+ Column(
52
+ children: <Widget>[
53
+ const Text('Header'),
54
+ ListView(
55
+ children: const <Widget>[
56
+ ListTile(title: Text('Item 1')),
57
+ ListTile(title: Text('Item 2')),
58
+ ],
59
+ ),
60
+ ],
61
+ )
62
+ ```
63
+
64
+ **Output (Resolved State):**
65
+ ```dart
66
+ // Wrap ListView in Expanded to constrain its height to the remaining Column space
67
+ Column(
68
+ children: <Widget>[
69
+ const Text('Header'),
70
+ Expanded(
71
+ child: ListView(
72
+ children: const <Widget>[
73
+ ListTile(title: Text('Item 1')),
74
+ ListTile(title: Text('Item 2')),
75
+ ],
76
+ ),
77
+ ),
78
+ ],
79
+ )
80
+ ```
81
+
82
+ ### Fixing Unbounded Width (TextField in Row)
83
+
84
+ **Input (Error State):**
85
+ ```dart
86
+ // Throws "An InputDecorator...cannot have an unbounded width"
87
+ Row(
88
+ children: [
89
+ const Icon(Icons.search),
90
+ TextField(),
91
+ ],
92
+ )
93
+ ```
94
+
95
+ **Output (Resolved State):**
96
+ ```dart
97
+ // Wrap TextField in Expanded to constrain its width to the remaining Row space
98
+ Row(
99
+ children: [
100
+ const Icon(Icons.search),
101
+ Expanded(
102
+ child: TextField(),
103
+ ),
104
+ ],
105
+ )
106
+ ```
107
+
108
+ ### Fixing RenderFlex Overflow
109
+
110
+ **Input (Error State):**
111
+ ```dart
112
+ // Throws "A RenderFlex overflowed by X pixels on the right"
113
+ Row(
114
+ children: [
115
+ const Icon(Icons.info),
116
+ const Text('This is a very long text string that will definitely overflow the available screen width and cause a RenderFlex error.'),
117
+ ],
118
+ )
119
+ ```
120
+
121
+ **Output (Resolved State):**
122
+ ```dart
123
+ // Wrap the Text widget in Expanded to force it to wrap within the available constraints
124
+ Row(
125
+ children: [
126
+ const Icon(Icons.info),
127
+ Expanded(
128
+ child: const Text('This is a very long text string that will definitely overflow the available screen width and cause a RenderFlex error.'),
129
+ ),
130
+ ],
131
+ )
132
+ ```
@@ -0,0 +1,155 @@
1
+ 【claude code调用标识:flutter-implement-json-serialization】【trae调用标识:flutter-implement-json-serialization+Flutter开发】【流程场景:1.完整3阶段SDD流程、3.小型功能迭代】
2
+
3
+ ---
4
+ name: flutter-implement-json-serialization
5
+ description: Create model classes with `fromJson` and `toJson` methods using `dart:convert`. Use when manually mapping JSON keys to class properties for simple data structures.
6
+ metadata:
7
+ model: models/gemini-3.1-pro-preview
8
+ last_modified: Tue, 21 Apr 2026 21:44:50 GMT
9
+ ---
10
+ # Serializing JSON Manually in Flutter
11
+
12
+ ## Contents
13
+ - [Core Guidelines](#core-guidelines)
14
+ - [Workflow: Implementing a Serializable Model](#workflow-implementing-a-serializable-model)
15
+ - [Workflow: Fetching and Parsing JSON](#workflow-fetching-and-parsing-json)
16
+ - [Examples](#examples)
17
+
18
+ ## Core Guidelines
19
+
20
+ - **Import `dart:convert`**: Utilize Flutter's built-in `dart:convert` library for manual JSON encoding (`jsonEncode`) and decoding (`jsonDecode`).
21
+ - **Enforce Type Safety**: Always cast the `dynamic` result of `jsonDecode()` to the expected type, typically `Map<String, dynamic>` for objects or `List<dynamic>` for arrays.
22
+ - **Encapsulate Serialization Logic**: Define plain model classes containing properties corresponding to the JSON structure. Implement a `fromJson` factory constructor and a `toJson` method within the model.
23
+ - **Handle Background Parsing**: If parsing large JSON documents (execution time > 16ms), offload the parsing logic to a separate isolate using Flutter's `compute()` function to prevent UI jank.
24
+ - **Throw Exceptions on Failure**: When handling HTTP responses, throw an exception if the status code is not successful (e.g., not 200 OK or 201 Created). Do not return `null`.
25
+
26
+ ## Workflow: Implementing a Serializable Model
27
+
28
+ Use this checklist to implement manual JSON serialization for a data model.
29
+
30
+ **Task Progress:**
31
+ - [ ] Define the plain model class with `final` properties.
32
+ - [ ] Implement the `factory Model.fromJson(Map<String, dynamic> json)` constructor.
33
+ - [ ] Implement the `Map<String, dynamic> toJson()` method.
34
+ - [ ] Write unit tests for both serialization methods.
35
+ - [ ] Run validator -> review type mismatch errors -> fix casting logic.
36
+
37
+ 1. **Define the Model**: Create a class with properties matching the JSON keys.
38
+ 2. **Implement `fromJson`**: Extract values from the `Map` and cast them to the appropriate Dart types. Use pattern matching or explicit casting.
39
+ 3. **Implement `toJson`**: Return a `Map<String, dynamic>` mapping the class properties back to their JSON string keys.
40
+ 4. **Validate**: Execute unit tests to ensure type safety, autocompletion, and compile-time exception handling function correctly.
41
+
42
+ ## Workflow: Fetching and Parsing JSON
43
+
44
+ Use this conditional workflow when retrieving and parsing JSON from a network request.
45
+
46
+ **Task Progress:**
47
+ - [ ] Execute the HTTP request.
48
+ - [ ] Validate the response status code.
49
+ - [ ] Determine parsing strategy (Synchronous vs. Isolate).
50
+ - [ ] Decode and map the JSON to the model.
51
+
52
+ 1. **Execute Request**: Use the `http` package to perform the network call.
53
+ 2. **Validate Response**:
54
+ - If `response.statusCode == 200` (or 201 for POST), proceed to parsing.
55
+ - If the status code indicates failure, throw an `Exception`.
56
+ 3. **Determine Parsing Strategy**:
57
+ - If parsing a **small payload** (e.g., a single object), parse synchronously on the main thread.
58
+ - If parsing a **large payload** (e.g., an array of thousands of objects), use `compute(parseFunction, response.body)` to parse in a background isolate.
59
+ 4. **Decode and Map**: Pass the decoded JSON to your model's `fromJson` constructor.
60
+
61
+ ## Examples
62
+
63
+ ### High-Fidelity Model Implementation
64
+
65
+ ```dart
66
+ import 'dart:convert';
67
+
68
+ class User {
69
+ final int id;
70
+ final String name;
71
+ final String email;
72
+
73
+ const User({
74
+ required this.id,
75
+ required this.name,
76
+ required this.email,
77
+ });
78
+
79
+ // Factory constructor for deserialization
80
+ factory User.fromJson(Map<String, dynamic> json) {
81
+ return switch (json) {
82
+ {
83
+ 'id': int id,
84
+ 'name': String name,
85
+ 'email': String email,
86
+ } =>
87
+ User(
88
+ id: id,
89
+ name: name,
90
+ email: email,
91
+ ),
92
+ _ => throw const FormatException('Failed to load User.'),
93
+ };
94
+ }
95
+
96
+ // Method for serialization
97
+ Map<String, dynamic> toJson() {
98
+ return {
99
+ 'id': id,
100
+ 'name': name,
101
+ 'email': email,
102
+ };
103
+ }
104
+ }
105
+ ```
106
+
107
+ ### Synchronous Parsing (Small Payload)
108
+
109
+ ```dart
110
+ import 'dart:convert';
111
+ import 'package:http/http.dart' as http;
112
+
113
+ Future<User> fetchUser(http.Client client, int userId) async {
114
+ final response = await client.get(
115
+ Uri.parse('https://api.example.com/users/$userId'),
116
+ headers: {'Accept': 'application/json'},
117
+ );
118
+
119
+ if (response.statusCode == 200) {
120
+ // Decode returns dynamic, cast to Map<String, dynamic>
121
+ final Map<String, dynamic> jsonMap = jsonDecode(response.body) as Map<String, dynamic>;
122
+ return User.fromJson(jsonMap);
123
+ } else {
124
+ throw Exception('Failed to load user');
125
+ }
126
+ }
127
+ ```
128
+
129
+ ### Background Parsing (Large Payload)
130
+
131
+ ```dart
132
+ import 'dart:convert';
133
+ import 'package:flutter/foundation.dart';
134
+ import 'package:http/http.dart' as http;
135
+
136
+ // Top-level function required for compute()
137
+ List<User> parseUsers(String responseBody) {
138
+ final parsed = (jsonDecode(responseBody) as List<dynamic>).cast<Map<String, dynamic>>();
139
+ return parsed.map<User>((json) => User.fromJson(json)).toList();
140
+ }
141
+
142
+ Future<List<User>> fetchUsers(http.Client client) async {
143
+ final response = await client.get(
144
+ Uri.parse('https://api.example.com/users'),
145
+ headers: {'Accept': 'application/json'},
146
+ );
147
+
148
+ if (response.statusCode == 200) {
149
+ // Offload expensive parsing to a background isolate
150
+ return compute(parseUsers, response.body);
151
+ } else {
152
+ throw Exception('Failed to load users');
153
+ }
154
+ }
155
+ ```
@@ -0,0 +1,257 @@
1
+ 【claude code调用标识:flutter-setup-declarative-routing】【trae调用标识:flutter-setup-declarative-routing+Flutter开发】【流程场景:1.完整3阶段SDD流程、2.从零开始新项目】
2
+
3
+ ---
4
+ name: flutter-setup-declarative-routing
5
+ description: Configure `MaterialApp.router` using a package like `go_router` for advanced URL-based navigation. Use when developing web applications or mobile apps that require specific deep linking and browser history support.
6
+ metadata:
7
+ model: models/gemini-3.1-pro-preview
8
+ last_modified: Tue, 21 Apr 2026 21:08:03 GMT
9
+ ---
10
+ # Implementing Routing and Deep Linking
11
+
12
+ ## Contents
13
+ - [Core Concepts](#core-concepts)
14
+ - [Workflow: Initializing the Application and Router](#workflow-initializing-the-application-and-router)
15
+ - [Workflow: Configuring Platform Deep Linking](#workflow-configuring-platform-deep-linking)
16
+ - [Workflow: Implementing Nested Navigation](#workflow-implementing-nested-navigation)
17
+ - [Examples](#examples)
18
+
19
+ ## Core Concepts
20
+
21
+ Use the `go_router` package for declarative routing in Flutter. It provides a robust API for complex routing scenarios, deep linking, and nested navigation.
22
+
23
+ - **GoRouter**: The central configuration object defining the application's route tree.
24
+ - **GoRoute**: A standard route mapping a URL path to a Flutter screen.
25
+ - **ShellRoute / StatefulShellRoute**: Wraps child routes in a persistent UI shell (e.g., a `BottomNavigationBar`). `StatefulShellRoute` maintains the state of parallel navigation branches.
26
+ - **Path URL Strategy**: Removes the default `#` fragment from web URLs, essential for clean deep linking across platforms.
27
+
28
+ ## Workflow: Initializing the Application and Router
29
+
30
+ Follow this workflow to bootstrap a new Flutter application with `go_router` and configure the root routing mechanism.
31
+
32
+ ### Task Progress
33
+ - [ ] Create the Flutter application.
34
+ - [ ] Add the `go_router` dependency.
35
+ - [ ] Configure the URL strategy for web/deep linking.
36
+ - [ ] Implement the `GoRouter` configuration.
37
+ - [ ] Bind the router to `MaterialApp.router`.
38
+
39
+ ### 1. Scaffold the Application
40
+ Run the following commands to create the app and add the required routing package:
41
+ ```bash
42
+ flutter create <app-name>
43
+ cd <app-name>
44
+ flutter pub add go_router
45
+ ```
46
+
47
+ ### 2. Configure the Router
48
+ Define a top-level `GoRouter` instance. Handle authentication or state-based routing using the `redirect` parameter.
49
+
50
+ ```dart
51
+ import 'package:flutter/material.dart';
52
+ import 'package:go_router/go_router.dart';
53
+ import 'package:flutter_web_plugins/url_strategy.dart';
54
+
55
+ void main() {
56
+ // Use path URL strategy to remove the '#' from web URLs
57
+ usePathUrlStrategy();
58
+ runApp(const MyApp());
59
+ }
60
+
61
+ final GoRouter _router = GoRouter(
62
+ initialLocation: '/',
63
+ routes: [
64
+ GoRoute(
65
+ path: '/',
66
+ builder: (context, state) => const HomeScreen(),
67
+ routes: [
68
+ GoRoute(
69
+ path: 'details/:id',
70
+ builder: (context, state) => DetailsScreen(id: state.pathParameters['id']!),
71
+ ),
72
+ ],
73
+ ),
74
+ ],
75
+ errorBuilder: (context, state) => ErrorScreen(error: state.error),
76
+ );
77
+
78
+ class MyApp extends StatelessWidget {
79
+ const MyApp({super.key});
80
+
81
+ @override
82
+ Widget build(BuildContext context) {
83
+ return MaterialApp.router(
84
+ routerConfig: _router,
85
+ title: 'Routing App',
86
+ );
87
+ }
88
+ }
89
+ ```
90
+
91
+ ## Workflow: Configuring Platform Deep Linking
92
+
93
+ Configure the native platforms to intercept specific URLs and route them into the Flutter application.
94
+
95
+ ### Task Progress
96
+ - [ ] Determine target platforms (iOS, Android, or both).
97
+ - [ ] Apply conditional configuration for Android (Manifest + Asset Links).
98
+ - [ ] Apply conditional configuration for iOS (Plist + Entitlements + AASA).
99
+ - [ ] Run validator -> review errors -> fix.
100
+
101
+ ### If configuring for Android:
102
+ 1. **Modify `AndroidManifest.xml`**: Add the intent filter inside the `<activity>` tag for `.MainActivity`.
103
+ ```xml
104
+ <intent-filter android:autoVerify="true">
105
+ <action android:name="android.intent.action.VIEW" />
106
+ <category android:name="android.intent.category.DEFAULT" />
107
+ <category android:name="android.intent.category.BROWSABLE" />
108
+ <data android:scheme="http" android:host="yourdomain.com" />
109
+ <data android:scheme="https" />
110
+ </intent-filter>
111
+ ```
112
+ 2. **Host `assetlinks.json`**: Serve the following JSON at `https://yourdomain.com/.well-known/assetlinks.json`.
113
+ ```json
114
+ [{
115
+ "relation": ["delegate_permission/common.handle_all_urls"],
116
+ "target": {
117
+ "namespace": "android_app",
118
+ "package_name": "com.yourcompany.yourapp",
119
+ "sha256_cert_fingerprints": ["YOUR_SHA256_FINGERPRINT"]
120
+ }
121
+ }]
122
+ ```
123
+
124
+ ### If configuring for iOS:
125
+ 1. **Modify `Info.plist`**: Opt-in to Flutter's default deep link handler.
126
+ *Note: If using a third-party deep linking plugin (e.g., `app_links`), set this to `NO` to prevent conflicts.*
127
+ ```xml
128
+ <key>FlutterDeepLinkingEnabled</key>
129
+ <true/>
130
+ ```
131
+ 2. **Modify `Runner.entitlements`**: Add the associated domain.
132
+ ```xml
133
+ <key>com.apple.developer.associated-domains</key>
134
+ <array>
135
+ <string>applinks:yourdomain.com</string>
136
+ </array>
137
+ ```
138
+ 3. **Host `apple-app-site-association`**: Serve the following JSON (without a `.json` extension) at `https://yourdomain.com/.well-known/apple-app-site-association`.
139
+ ```json
140
+ {
141
+ "applinks": {
142
+ "apps": [],
143
+ "details": [{
144
+ "appIDs": ["TEAM_ID.com.yourcompany.yourapp"],
145
+ "paths": ["*"],
146
+ "components": [{"/": "/*"}]
147
+ }]
148
+ }
149
+ }
150
+ ```
151
+
152
+ ### Validation Loop
153
+ Run validator -> review errors -> fix.
154
+ - **Android**: Test using ADB.
155
+ ```bash
156
+ adb shell 'am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "https://yourdomain.com/details/123"' com.yourcompany.yourapp
157
+ ```
158
+ - **iOS**: Test using `xcrun` on a booted simulator.
159
+ ```bash
160
+ xcrun simctl openurl booted https://yourdomain.com/details/123
161
+ ```
162
+
163
+ ## Workflow: Implementing Nested Navigation
164
+
165
+ Use `StatefulShellRoute` to implement persistent UI shells (like a bottom navigation bar) that maintain the state of their child routes.
166
+
167
+ ### Task Progress
168
+ - [ ] Define `StatefulShellRoute.indexedStack` in the `GoRouter` configuration.
169
+ - [ ] Create `StatefulShellBranch` instances for each navigation tab.
170
+ - [ ] Implement the shell widget using `StatefulNavigationShell`.
171
+
172
+ ```dart
173
+ final GoRouter _router = GoRouter(
174
+ initialLocation: '/home',
175
+ routes: [
176
+ StatefulShellRoute.indexedStack(
177
+ builder: (context, state, navigationShell) {
178
+ return ScaffoldWithNavBar(navigationShell: navigationShell);
179
+ },
180
+ branches: [
181
+ StatefulShellBranch(
182
+ routes: [
183
+ GoRoute(
184
+ path: '/home',
185
+ builder: (context, state) => const HomeScreen(),
186
+ ),
187
+ ],
188
+ ),
189
+ StatefulShellBranch(
190
+ routes: [
191
+ GoRoute(
192
+ path: '/settings',
193
+ builder: (context, state) => const SettingsScreen(),
194
+ ),
195
+ ],
196
+ ),
197
+ ],
198
+ ),
199
+ ],
200
+ );
201
+ ```
202
+
203
+ ## Examples
204
+
205
+ ### High-Fidelity Shell Widget Implementation
206
+ Implement the UI shell that consumes the `StatefulNavigationShell` to handle branch switching.
207
+
208
+ ```dart
209
+ class ScaffoldWithNavBar extends StatelessWidget {
210
+ const ScaffoldWithNavBar({
211
+ required this.navigationShell,
212
+ super.key,
213
+ });
214
+
215
+ final StatefulNavigationShell navigationShell;
216
+
217
+ void _goBranch(int index) {
218
+ navigationShell.goBranch(
219
+ index,
220
+ // Support navigating to the initial location when tapping the active tab.
221
+ initialLocation: index == navigationShell.currentIndex,
222
+ );
223
+ }
224
+
225
+ @override
226
+ Widget build(BuildContext context) {
227
+ return Scaffold(
228
+ body: navigationShell,
229
+ bottomNavigationBar: NavigationBar(
230
+ selectedIndex: navigationShell.currentIndex,
231
+ onDestinationSelected: _goBranch,
232
+ destinations: const [
233
+ NavigationDestination(icon: Icon(Icons.home), label: 'Home'),
234
+ NavigationDestination(icon: Icon(Icons.settings), label: 'Settings'),
235
+ ],
236
+ ),
237
+ );
238
+ }
239
+ }
240
+ ```
241
+
242
+ ### Programmatic Navigation
243
+ Use the `context.go()` and `context.push()` extension methods provided by `go_router`.
244
+
245
+ ```dart
246
+ // Replaces the current route stack with the target route (Declarative)
247
+ context.go('/details/123');
248
+
249
+ // Pushes the target route onto the existing stack (Imperative)
250
+ context.push('/details/123');
251
+
252
+ // Navigates using a named route and path parameters
253
+ context.goNamed('details', pathParameters: {'id': '123'});
254
+
255
+ // Pops the current route
256
+ context.pop();
257
+ ```