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.
- package/bin.js +1 -1
- package/package.json +1 -1
- package/skills/.agents/skills/flutter-add-integration-test/SKILL.md +165 -0
- package/skills/.agents/skills/flutter-add-widget-preview/SKILL.md +147 -0
- package/skills/.agents/skills/flutter-add-widget-test/SKILL.md +156 -0
- package/skills/.agents/skills/flutter-apply-architecture-best-practices/SKILL.md +164 -0
- package/skills/.agents/skills/flutter-build-responsive-layout/SKILL.md +141 -0
- package/skills/.agents/skills/flutter-fix-layout-issues/SKILL.md +132 -0
- package/skills/.agents/skills/flutter-implement-json-serialization/SKILL.md +155 -0
- package/skills/.agents/skills/flutter-setup-declarative-routing/SKILL.md +257 -0
- package/skills/.agents/skills/flutter-setup-localization/SKILL.md +212 -0
- package/skills/.agents/skills/flutter-use-http-package/SKILL.md +177 -0
- package/skills/VERSION.md +176 -62
- package/skills/design-planning/ai-coding-rules/SKILL.md +5 -13
- package/skills/design-planning/design-to-code/SKILL.md +5 -14
- package/skills/design-planning/enterprise-spec/SKILL.md +5 -13
- package/skills/design-planning/flutter-av/SKILL.md +5 -16
- package/skills/design-planning/flutter-map/SKILL.md +5 -14
- package/skills/design-planning/function-sdd/SKILL.md +5 -13
- package/skills/design-planning/global-overlay-stack-standard/SKILL.md +73 -0
- package/skills/design-planning/ui-motion-interaction-standard/SKILL.md +69 -0
- package/skills/design-planning/ui-sdd-specialized/SKILL.md +5 -14
- package/skills/development-execution/flutter-errors/SKILL.md +5 -15
- package/skills/flutter-skills/.github/dependabot.yaml +15 -0
- package/skills/flutter-skills/.github/workflows/dart_skills_lint_workflow.yaml +68 -0
- package/skills/flutter-skills/.github/workflows/skills_tool.yaml +51 -0
- package/skills/flutter-skills/CODE_OF_CONDUCT.md +3 -0
- package/skills/flutter-skills/CONTRIBUTING.md +36 -0
- package/skills/flutter-skills/LICENSE +26 -0
- package/skills/flutter-skills/README.md +50 -0
- package/skills/flutter-skills/pubspec.yaml +9 -0
- package/skills/flutter-skills/resources/flutter_skills.yaml +434 -0
- package/skills/flutter-skills/skills/flutter-add-integration-test/SKILL.md +163 -0
- package/skills/flutter-skills/skills/flutter-add-widget-preview/SKILL.md +145 -0
- package/skills/flutter-skills/skills/flutter-add-widget-test/SKILL.md +154 -0
- package/skills/flutter-skills/skills/flutter-apply-architecture-best-practices/SKILL.md +162 -0
- package/skills/flutter-skills/skills/flutter-build-responsive-layout/SKILL.md +139 -0
- package/skills/flutter-skills/skills/flutter-fix-layout-issues/SKILL.md +130 -0
- package/skills/flutter-skills/skills/flutter-implement-json-serialization/SKILL.md +153 -0
- package/skills/flutter-skills/skills/flutter-setup-declarative-routing/SKILL.md +255 -0
- package/skills/flutter-skills/skills/flutter-setup-localization/SKILL.md +210 -0
- package/skills/flutter-skills/skills/flutter-use-http-package/SKILL.md +175 -0
- package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/add-dart-lint-validation-rule/SKILL.md +196 -0
- package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-best-practices/SKILL.md +65 -0
- package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-checks-migration/SKILL.md +158 -0
- package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-cli-app-best-practices/SKILL.md +168 -0
- package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-doc-validation/SKILL.md +87 -0
- package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-long-lines/SKILL.md +101 -0
- package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-matcher-best-practices/SKILL.md +136 -0
- package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-modern-features/SKILL.md +266 -0
- package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-package-maintenance/SKILL.md +92 -0
- package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-test-coverage/SKILL.md +92 -0
- package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-test-coverage/example/lib/src/calculator.dart +7 -0
- package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-test-coverage/example/pubspec.yaml +8 -0
- package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-test-coverage/example/test/calculator_test.dart +11 -0
- package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-test-coverage/scripts/interpret_coverage.dart +95 -0
- package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-test-coverage/scripts/pubspec.yaml +6 -0
- package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-test-coverage/scripts/test/interpret_coverage_test.dart +93 -0
- package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-test-fundamentals/SKILL.md +173 -0
- package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/definition-of-done/SKILL.md +27 -0
- package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/flutter_skills_ignore.json +3 -0
- package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/grill-me/SKILL.md +10 -0
- package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/ignore.json +3 -0
- package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/test-driven-development/SKILL.md +371 -0
- package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/test-driven-development/testing-anti-patterns.md +299 -0
- package/skills/flutter-skills/tool/dart_skills_lint/AUTHORS +7 -0
- package/skills/flutter-skills/tool/dart_skills_lint/CHANGELOG.md +12 -0
- package/skills/flutter-skills/tool/dart_skills_lint/CONTRIBUTING.md +51 -0
- package/skills/flutter-skills/tool/dart_skills_lint/LICENSE +27 -0
- package/skills/flutter-skills/tool/dart_skills_lint/README.md +203 -0
- package/skills/flutter-skills/tool/dart_skills_lint/analysis_options.yaml +296 -0
- package/skills/flutter-skills/tool/dart_skills_lint/bench/README.md +23 -0
- package/skills/flutter-skills/tool/dart_skills_lint/bench/baseline_throughput.dart +230 -0
- package/skills/flutter-skills/tool/dart_skills_lint/bin/cli.dart +10 -0
- package/skills/flutter-skills/tool/dart_skills_lint/dart_skills_lint.yaml +14 -0
- package/skills/flutter-skills/tool/dart_skills_lint/documentation/feature_design_docs/PRODUCTION_READYNESS.md +48 -0
- package/skills/flutter-skills/tool/dart_skills_lint/documentation/feature_design_docs/completion_migration_plan.md +99 -0
- package/skills/flutter-skills/tool/dart_skills_lint/documentation/feature_design_docs/legacy_patterns_report.md +110 -0
- package/skills/flutter-skills/tool/dart_skills_lint/documentation/feature_design_docs/pub_vs_skill_report.md +56 -0
- package/skills/flutter-skills/tool/dart_skills_lint/documentation/knowledge/SPECIFICATION.md +79 -0
- package/skills/flutter-skills/tool/dart_skills_lint/documentation/knowledge/architecture_overview.md +64 -0
- package/skills/flutter-skills/tool/dart_skills_lint/lib/dart_skills_lint.dart +11 -0
- package/skills/flutter-skills/tool/dart_skills_lint/lib/src/config_parser.dart +156 -0
- package/skills/flutter-skills/tool/dart_skills_lint/lib/src/entry_point.dart +354 -0
- package/skills/flutter-skills/tool/dart_skills_lint/lib/src/fixable_rule.dart +20 -0
- package/skills/flutter-skills/tool/dart_skills_lint/lib/src/models/analysis_severity.dart +15 -0
- package/skills/flutter-skills/tool/dart_skills_lint/lib/src/models/check_type.dart +17 -0
- package/skills/flutter-skills/tool/dart_skills_lint/lib/src/models/ignore_entry.dart +34 -0
- package/skills/flutter-skills/tool/dart_skills_lint/lib/src/models/ignore_entry.g.dart +19 -0
- package/skills/flutter-skills/tool/dart_skills_lint/lib/src/models/skill_context.dart +27 -0
- package/skills/flutter-skills/tool/dart_skills_lint/lib/src/models/skill_rule.dart +27 -0
- package/skills/flutter-skills/tool/dart_skills_lint/lib/src/models/skills_ignores.dart +26 -0
- package/skills/flutter-skills/tool/dart_skills_lint/lib/src/models/skills_ignores.g.dart +24 -0
- package/skills/flutter-skills/tool/dart_skills_lint/lib/src/models/validation_error.dart +31 -0
- package/skills/flutter-skills/tool/dart_skills_lint/lib/src/rule_registry.dart +79 -0
- package/skills/flutter-skills/tool/dart_skills_lint/lib/src/rules/absolute_paths_rule.dart +74 -0
- package/skills/flutter-skills/tool/dart_skills_lint/lib/src/rules/description_length_rule.dart +49 -0
- package/skills/flutter-skills/tool/dart_skills_lint/lib/src/rules/disallowed_field_rule.dart +61 -0
- package/skills/flutter-skills/tool/dart_skills_lint/lib/src/rules/name_format_rule.dart +167 -0
- package/skills/flutter-skills/tool/dart_skills_lint/lib/src/rules/relative_paths_rule.dart +72 -0
- package/skills/flutter-skills/tool/dart_skills_lint/lib/src/rules/trailing_whitespace_rule.dart +93 -0
- package/skills/flutter-skills/tool/dart_skills_lint/lib/src/rules/valid_yaml_metadata_rule.dart +74 -0
- package/skills/flutter-skills/tool/dart_skills_lint/lib/src/skills_ignores_storage.dart +36 -0
- package/skills/flutter-skills/tool/dart_skills_lint/lib/src/validation_session.dart +559 -0
- package/skills/flutter-skills/tool/dart_skills_lint/lib/src/validator.dart +238 -0
- package/skills/flutter-skills/tool/dart_skills_lint/pubspec.yaml +28 -0
- package/skills/flutter-skills/tool/dart_skills_lint/skills/README.md +10 -0
- package/skills/flutter-skills/tool/dart_skills_lint/skills/dart-skills-lint-validation/SKILL.md +195 -0
- package/skills/flutter-skills/tool/dart_skills_lint/skills-lock.json +75 -0
- package/skills/flutter-skills/tool/dart_skills_lint/test/absolute_paths_test.dart +167 -0
- package/skills/flutter-skills/tool/dart_skills_lint/test/cli_integration_test.dart +683 -0
- package/skills/flutter-skills/tool/dart_skills_lint/test/config_file_test.dart +292 -0
- package/skills/flutter-skills/tool/dart_skills_lint/test/custom_rule_test.dart +122 -0
- package/skills/flutter-skills/tool/dart_skills_lint/test/directory_structure_test.dart +163 -0
- package/skills/flutter-skills/tool/dart_skills_lint/test/field_constraints_test.dart +178 -0
- package/skills/flutter-skills/tool/dart_skills_lint/test/fixer_test.dart +172 -0
- package/skills/flutter-skills/tool/dart_skills_lint/test/ignore_models_test.dart +63 -0
- package/skills/flutter-skills/tool/dart_skills_lint/test/metadata_validation_test.dart +116 -0
- package/skills/flutter-skills/tool/dart_skills_lint/test/relative_path_flag_test.dart +70 -0
- package/skills/flutter-skills/tool/dart_skills_lint/test/relative_paths_test.dart +172 -0
- package/skills/flutter-skills/tool/dart_skills_lint/test/resolve_rules_test.dart +82 -0
- package/skills/flutter-skills/tool/dart_skills_lint/test/rule_naming_test.dart +29 -0
- package/skills/flutter-skills/tool/dart_skills_lint/test/skills_ignores_storage_test.dart +89 -0
- package/skills/flutter-skills/tool/dart_skills_lint/test/test_utils.dart +19 -0
- package/skills/flutter-skills/tool/dart_skills_lint/test/trailing_whitespace_test.dart +152 -0
- package/skills/flutter-skills/tool/generator/README.md +150 -0
- package/skills/flutter-skills/tool/generator/analysis_options.yaml +143 -0
- package/skills/flutter-skills/tool/generator/bin/skills.dart +73 -0
- package/skills/flutter-skills/tool/generator/lib/src/commands/base_skill_command.dart +87 -0
- package/skills/flutter-skills/tool/generator/lib/src/commands/base_yaml_command.dart +83 -0
- package/skills/flutter-skills/tool/generator/lib/src/commands/generate_skill_command.dart +92 -0
- package/skills/flutter-skills/tool/generator/lib/src/commands/update_readme_command.dart +150 -0
- package/skills/flutter-skills/tool/generator/lib/src/commands/update_skill_command.dart +97 -0
- package/skills/flutter-skills/tool/generator/lib/src/commands/validate_skill_command.dart +284 -0
- package/skills/flutter-skills/tool/generator/lib/src/models/skill_params.dart +41 -0
- package/skills/flutter-skills/tool/generator/lib/src/services/gemini_service.dart +310 -0
- package/skills/flutter-skills/tool/generator/lib/src/services/markdown_converter.dart +226 -0
- package/skills/flutter-skills/tool/generator/lib/src/services/prompts.dart +72 -0
- package/skills/flutter-skills/tool/generator/lib/src/services/resource_fetcher_service.dart +84 -0
- package/skills/flutter-skills/tool/generator/lib/src/services/skill_instructions.dart +30 -0
- package/skills/flutter-skills/tool/generator/pubspec.yaml +32 -0
- package/skills/flutter-skills/tool/generator/test/commands/base_skill_command_test.dart +131 -0
- package/skills/flutter-skills/tool/generator/test/commands/validate_skills_input_test.dart +263 -0
- package/skills/flutter-skills/tool/generator/test/custom_skill_rules/last_modified_rule.dart +32 -0
- package/skills/flutter-skills/tool/generator/test/generate_skills_retry_test.dart +105 -0
- package/skills/flutter-skills/tool/generator/test/generate_skills_test.dart +519 -0
- package/skills/flutter-skills/tool/generator/test/lint_skills_test.dart +34 -0
- package/skills/flutter-skills/tool/generator/test/markdown_converter_test.dart +103 -0
- package/skills/flutter-skills/tool/generator/test/markdown_table_test.dart +131 -0
- package/skills/flutter-skills/tool/generator/test/models/skill_params_test.dart +37 -0
- package/skills/flutter-skills/tool/generator/test/services/gemini_service_test.dart +291 -0
- package/skills/flutter-skills/tool/generator/test/services/markdown_converter_test.dart +156 -0
- package/skills/flutter-skills/tool/generator/test/services/resource_fetcher_service_test.dart +188 -0
- package/skills/flutter-skills/tool/generator/test/update_skills_test.dart +241 -0
- package/skills/flutter-skills/tool/generator/test/validate_skills_test.dart +728 -0
- package/skills/quality-assurance/bdd-acceptance/SKILL.md +5 -14
- package/skills/quality-assurance/flutter-test/SKILL.md +5 -16
- package/skills/rules/project_rules.md +538 -127
- package/skills/special-tools/env-check/SKILL.md +5 -13
- package/skills/special-tools/ios-full-auto-debug/SKILL.md +5 -15
- package/skills/writing-skills/SKILL.md +654 -0
- package/skills/writing-skills/anthropic-best-practices.md +1149 -0
- package/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
- package/skills/writing-skills/graphviz-conventions.dot +172 -0
- package/skills/writing-skills/persuasion-principles.md +187 -0
- package/skills/writing-skills/render-graphs.js +168 -0
- package/skills/writing-skills/testing-skills-with-subagents.md +384 -0
- package/skills/checklist.md +0 -154
- package/skills/rules/user_rules.md +0 -263
- 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
- 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
- package/skills//346/212/200/350/203/275/344/275/277/347/224/250/346/214/207/345/215/227.md +0 -309
- package/skills//346/212/200/350/203/275/345/206/263/347/255/226/346/240/221.md +0 -338
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: flutter-setup-localization
|
|
3
|
+
description: Add `flutter_localizations` and `intl` dependencies, enable "generate true" in `pubspec.yaml`, and create an `l10n.yaml` configuration file. Use when initializing localization support for a new Flutter project.
|
|
4
|
+
metadata:
|
|
5
|
+
model: models/gemini-3.1-pro-preview
|
|
6
|
+
last_modified: Tue, 21 Apr 2026 21:27:35 GMT
|
|
7
|
+
---
|
|
8
|
+
# Internationalizing Flutter Applications
|
|
9
|
+
|
|
10
|
+
## Contents
|
|
11
|
+
- [Core Concepts](#core-concepts)
|
|
12
|
+
- [Setup Workflow](#setup-workflow)
|
|
13
|
+
- [Implementation Workflow](#implementation-workflow)
|
|
14
|
+
- [Advanced Formatting](#advanced-formatting)
|
|
15
|
+
- [Examples](#examples)
|
|
16
|
+
|
|
17
|
+
## Core Concepts
|
|
18
|
+
Flutter handles internationalization (i18n) and localization (l10n) via the `flutter_localizations` and `intl` packages. The standard approach uses App Resource Bundle (`.arb`) files to define localized strings, which are then compiled into a generated `AppLocalizations` class for type-safe access within the widget tree.
|
|
19
|
+
|
|
20
|
+
## Setup Workflow
|
|
21
|
+
|
|
22
|
+
Copy and track this checklist when initializing internationalization in a Flutter project:
|
|
23
|
+
|
|
24
|
+
- [ ] **Task Progress**
|
|
25
|
+
- [ ] 1. Add dependencies to `pubspec.yaml`.
|
|
26
|
+
- [ ] 2. Enable the `generate` flag.
|
|
27
|
+
- [ ] 3. Create the `l10n.yaml` configuration file.
|
|
28
|
+
- [ ] 4. Configure `MaterialApp` or `CupertinoApp`.
|
|
29
|
+
|
|
30
|
+
### 1. Add Dependencies
|
|
31
|
+
Add the required localization packages to the project. Execute the following commands in the terminal:
|
|
32
|
+
```bash
|
|
33
|
+
flutter pub add flutter_localizations --sdk=flutter
|
|
34
|
+
flutter pub add intl:any
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Verify your `pubspec.yaml` includes the following under `dependencies`:
|
|
38
|
+
```yaml
|
|
39
|
+
dependencies:
|
|
40
|
+
flutter:
|
|
41
|
+
sdk: flutter
|
|
42
|
+
flutter_localizations:
|
|
43
|
+
sdk: flutter
|
|
44
|
+
intl: any
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 2. Enable Code Generation
|
|
48
|
+
Open `pubspec.yaml` and enable the `generate` flag within the `flutter` section to automate localization tasks:
|
|
49
|
+
```yaml
|
|
50
|
+
flutter:
|
|
51
|
+
generate: true
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 3. Create Configuration File
|
|
55
|
+
Create a new file named `l10n.yaml` in the root directory of the Flutter project. Define the input directory, template file, and output file:
|
|
56
|
+
```yaml
|
|
57
|
+
arb-dir: lib/l10n
|
|
58
|
+
template-arb-file: app_en.arb
|
|
59
|
+
output-localization-file: app_localizations.dart
|
|
60
|
+
synthetic-package: true
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 4. Configure the App Entry Point
|
|
64
|
+
Import the generated localizations and the `flutter_localizations` library in your `main.dart`. Inject the delegates and supported locales into your `MaterialApp` or `CupertinoApp`.
|
|
65
|
+
|
|
66
|
+
```dart
|
|
67
|
+
import 'package:flutter_localizations/flutter_localizations.dart';
|
|
68
|
+
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; // Adjust path if synthetic-package is false
|
|
69
|
+
|
|
70
|
+
// ... inside build method
|
|
71
|
+
return MaterialApp(
|
|
72
|
+
localizationsDelegates: const [
|
|
73
|
+
AppLocalizations.delegate,
|
|
74
|
+
GlobalMaterialLocalizations.delegate,
|
|
75
|
+
GlobalWidgetsLocalizations.delegate,
|
|
76
|
+
GlobalCupertinoLocalizations.delegate,
|
|
77
|
+
],
|
|
78
|
+
supportedLocales: const [
|
|
79
|
+
Locale('en'), // English
|
|
80
|
+
Locale('es'), // Spanish
|
|
81
|
+
],
|
|
82
|
+
home: const MyHomePage(),
|
|
83
|
+
);
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Implementation Workflow
|
|
87
|
+
|
|
88
|
+
Follow this workflow when adding or modifying localized content.
|
|
89
|
+
|
|
90
|
+
### 1. Define ARB Files
|
|
91
|
+
* **If creating NEW content:** Add the base string to the template file (`lib/l10n/app_en.arb`). Include a description for context.
|
|
92
|
+
* **If EDITING existing content:** Locate the key in all supported `.arb` files and update the values.
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"helloWorld": "Hello World!",
|
|
97
|
+
"@helloWorld": {
|
|
98
|
+
"description": "The conventional newborn programmer greeting"
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Create corresponding files for other locales (e.g., `app_es.arb`):
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"helloWorld": "¡Hola Mundo!"
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### 2. Generate Localization Classes
|
|
111
|
+
Run the following command to trigger code generation:
|
|
112
|
+
```bash
|
|
113
|
+
flutter pub get
|
|
114
|
+
```
|
|
115
|
+
*Feedback Loop:* Run validator -> review terminal output for ARB syntax errors -> fix missing commas or mismatched placeholders -> re-run `flutter pub get`.
|
|
116
|
+
|
|
117
|
+
### 3. Consume Localized Strings
|
|
118
|
+
Access the localized strings in your widget tree using `AppLocalizations.of(context)`. Ensure the widget calling this is a descendant of `MaterialApp`.
|
|
119
|
+
|
|
120
|
+
```dart
|
|
121
|
+
Text(AppLocalizations.of(context)!.helloWorld)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Advanced Formatting
|
|
125
|
+
|
|
126
|
+
Use placeholders for dynamic data, plurals, and conditional selects.
|
|
127
|
+
|
|
128
|
+
### Placeholders
|
|
129
|
+
Define parameters within curly braces and specify their type in the metadata object.
|
|
130
|
+
```json
|
|
131
|
+
"hello": "Hello {userName}",
|
|
132
|
+
"@hello": {
|
|
133
|
+
"description": "A message with a single parameter",
|
|
134
|
+
"placeholders": {
|
|
135
|
+
"userName": {
|
|
136
|
+
"type": "String",
|
|
137
|
+
"example": "Bob"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Plurals
|
|
144
|
+
Use the `plural` syntax to handle quantity-based string variations. The `other` case is mandatory.
|
|
145
|
+
```json
|
|
146
|
+
"nWombats": "{count, plural, =0{no wombats} =1{1 wombat} other{{count} wombats}}",
|
|
147
|
+
"@nWombats": {
|
|
148
|
+
"description": "A plural message",
|
|
149
|
+
"placeholders": {
|
|
150
|
+
"count": {
|
|
151
|
+
"type": "num",
|
|
152
|
+
"format": "compact"
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Selects
|
|
159
|
+
Use the `select` syntax for conditional strings, such as gendered text.
|
|
160
|
+
```json
|
|
161
|
+
"pronoun": "{gender, select, male{he} female{she} other{they}}",
|
|
162
|
+
"@pronoun": {
|
|
163
|
+
"description": "A gendered message",
|
|
164
|
+
"placeholders": {
|
|
165
|
+
"gender": {
|
|
166
|
+
"type": "String"
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Examples
|
|
173
|
+
|
|
174
|
+
### Complete `l10n.yaml`
|
|
175
|
+
```yaml
|
|
176
|
+
arb-dir: lib/l10n
|
|
177
|
+
template-arb-file: app_en.arb
|
|
178
|
+
output-localization-file: app_localizations.dart
|
|
179
|
+
synthetic-package: true
|
|
180
|
+
use-escaping: true
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Complete Widget Implementation
|
|
184
|
+
```dart
|
|
185
|
+
import 'package:flutter/material.dart';
|
|
186
|
+
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
|
187
|
+
|
|
188
|
+
class GreetingWidget extends StatelessWidget {
|
|
189
|
+
final String userName;
|
|
190
|
+
final int notificationCount;
|
|
191
|
+
|
|
192
|
+
const GreetingWidget({
|
|
193
|
+
super.key,
|
|
194
|
+
required this.userName,
|
|
195
|
+
required this.notificationCount,
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
@override
|
|
199
|
+
Widget build(BuildContext context) {
|
|
200
|
+
final l10n = AppLocalizations.of(context)!;
|
|
201
|
+
|
|
202
|
+
return Column(
|
|
203
|
+
children: [
|
|
204
|
+
Text(l10n.hello(userName)),
|
|
205
|
+
Text(l10n.nWombats(notificationCount)),
|
|
206
|
+
],
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
```
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: flutter-use-http-package
|
|
3
|
+
description: Use the `http` package to execute GET, POST, PUT, or DELETE requests. Use when you need to fetch from or send data to a REST API.
|
|
4
|
+
metadata:
|
|
5
|
+
model: models/gemini-3.1-pro-preview
|
|
6
|
+
last_modified: Tue, 21 Apr 2026 21:36:42 GMT
|
|
7
|
+
---
|
|
8
|
+
# Implementing Flutter Networking
|
|
9
|
+
|
|
10
|
+
## Contents
|
|
11
|
+
- [Configuration & Permissions](#configuration--permissions)
|
|
12
|
+
- [Request Execution & Response Handling](#request-execution--response-handling)
|
|
13
|
+
- [Background Parsing](#background-parsing)
|
|
14
|
+
- [Workflow: Executing Network Operations](#workflow-executing-network-operations)
|
|
15
|
+
- [Examples](#examples)
|
|
16
|
+
|
|
17
|
+
## Configuration & Permissions
|
|
18
|
+
|
|
19
|
+
Configure the environment and platform-specific permissions required for network access.
|
|
20
|
+
|
|
21
|
+
1. Add the `http` package dependency via the terminal:
|
|
22
|
+
```bash
|
|
23
|
+
flutter pub add http
|
|
24
|
+
```
|
|
25
|
+
2. Import the package in your Dart files:
|
|
26
|
+
```dart
|
|
27
|
+
import 'package:http/http.dart' as http;
|
|
28
|
+
```
|
|
29
|
+
3. Configure Android permissions by adding the Internet permission to `android/app/src/main/AndroidManifest.xml`:
|
|
30
|
+
```xml
|
|
31
|
+
<uses-permission android:name="android.permission.INTERNET" />
|
|
32
|
+
```
|
|
33
|
+
4. Configure macOS entitlements by adding the network client key to both `macos/Runner/DebugProfile.entitlements` and `macos/Runner/Release.entitlements`:
|
|
34
|
+
```xml
|
|
35
|
+
<key>com.apple.security.network.client</key>
|
|
36
|
+
<true/>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Request Execution & Response Handling
|
|
40
|
+
|
|
41
|
+
Execute HTTP operations and map responses to strongly typed Dart objects.
|
|
42
|
+
|
|
43
|
+
* **URIs:** Always parse URL strings using `Uri.parse('your_url')`.
|
|
44
|
+
* **Headers:** Inject authorization and content-type headers via the `headers` parameter map. Use `HttpHeaders.authorizationHeader` for auth tokens.
|
|
45
|
+
* **Payloads:** For POST and PUT requests, encode the body using `jsonEncode()` from `dart:convert`.
|
|
46
|
+
* **Status Validation:** Evaluate `response.statusCode`. Treat `200 OK` (GET/PUT/DELETE) and `201 CREATED` (POST) as success.
|
|
47
|
+
* **Error Handling:** Throw explicit exceptions for non-success status codes. Never return `null` on failure, as this prevents `FutureBuilder` from triggering its error state and causes infinite loading indicators.
|
|
48
|
+
* **Deserialization:** Parse the raw string using `jsonDecode(response.body)` and map it to a custom Dart object using a factory constructor (e.g., `fromJson`).
|
|
49
|
+
|
|
50
|
+
## Background Parsing
|
|
51
|
+
|
|
52
|
+
Offload expensive JSON parsing to a separate Isolate to prevent UI jank (frame drops).
|
|
53
|
+
|
|
54
|
+
* Import `package:flutter/foundation.dart`.
|
|
55
|
+
* Use the `compute()` function to run the parsing logic in a background isolate.
|
|
56
|
+
* Ensure the parsing function passed to `compute()` is a top-level function or a static method, as closures or instance methods cannot be passed across isolates.
|
|
57
|
+
|
|
58
|
+
## Workflow: Executing Network Operations
|
|
59
|
+
|
|
60
|
+
Use the following checklist to implement and validate network operations.
|
|
61
|
+
|
|
62
|
+
**Task Progress:**
|
|
63
|
+
- [ ] 1. Define the strongly typed Dart model with a `fromJson` factory constructor.
|
|
64
|
+
- [ ] 2. Implement the network request method returning a `Future<Model>`.
|
|
65
|
+
- [ ] 3. Apply conditional logic based on the operation type:
|
|
66
|
+
- **If fetching data (GET):** Append query parameters to the URI.
|
|
67
|
+
- **If mutating data (POST/PUT):** Set `'Content-Type': 'application/json; charset=UTF-8'` and attach the `jsonEncode` body.
|
|
68
|
+
- **If deleting data (DELETE):** Return an empty model instance on success (`200 OK`).
|
|
69
|
+
- [ ] 4. Validate the `statusCode` and throw an `Exception` on failure.
|
|
70
|
+
- [ ] 5. Integrate the `Future` into the UI using `FutureBuilder`.
|
|
71
|
+
- [ ] 6. Handle `snapshot.hasData`, `snapshot.hasError`, and default to a `CircularProgressIndicator`.
|
|
72
|
+
- [ ] 7. **Feedback Loop:** Run the app -> trigger the network request -> review console for unhandled exceptions -> fix parsing or permission errors.
|
|
73
|
+
|
|
74
|
+
## Examples
|
|
75
|
+
|
|
76
|
+
### High-Fidelity Implementation: Fetching and Parsing in the Background
|
|
77
|
+
|
|
78
|
+
```dart
|
|
79
|
+
import 'dart:async';
|
|
80
|
+
import 'dart:convert';
|
|
81
|
+
import 'dart:io';
|
|
82
|
+
import 'package:flutter/foundation.dart';
|
|
83
|
+
import 'package:flutter/material.dart';
|
|
84
|
+
import 'package:http/http.dart' as http;
|
|
85
|
+
|
|
86
|
+
// 1. Top-level parsing function for Isolate
|
|
87
|
+
List<Photo> parsePhotos(String responseBody) {
|
|
88
|
+
final parsed = (jsonDecode(responseBody) as List<Object?>)
|
|
89
|
+
.cast<Map<String, Object?>>();
|
|
90
|
+
return parsed.map<Photo>(Photo.fromJson).toList();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// 2. Network execution with background parsing
|
|
94
|
+
Future<List<Photo>> fetchPhotos() async {
|
|
95
|
+
final response = await http.get(
|
|
96
|
+
Uri.parse('https://jsonplaceholder.typicode.com/photos'),
|
|
97
|
+
headers: {
|
|
98
|
+
HttpHeaders.authorizationHeader: 'Bearer your_token_here',
|
|
99
|
+
HttpHeaders.acceptHeader: 'application/json',
|
|
100
|
+
},
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
if (response.statusCode == 200) {
|
|
104
|
+
// Offload heavy parsing to a background isolate
|
|
105
|
+
return compute(parsePhotos, response.body);
|
|
106
|
+
} else {
|
|
107
|
+
throw Exception('Failed to load photos. Status: ${response.statusCode}');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// 3. Strongly typed model
|
|
113
|
+
class Photo {
|
|
114
|
+
final int id;
|
|
115
|
+
final String title;
|
|
116
|
+
final String thumbnailUrl;
|
|
117
|
+
|
|
118
|
+
const Photo({
|
|
119
|
+
required this.id,
|
|
120
|
+
required this.title,
|
|
121
|
+
required this.thumbnailUrl,
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
factory Photo.fromJson(Map<String, dynamic> json) {
|
|
125
|
+
return Photo(
|
|
126
|
+
id: json['id'] as int,
|
|
127
|
+
title: json['title'] as String,
|
|
128
|
+
thumbnailUrl: json['thumbnailUrl'] as String,
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// 4. UI Integration
|
|
134
|
+
class PhotoGallery extends StatefulWidget {
|
|
135
|
+
const PhotoGallery({super.key});
|
|
136
|
+
|
|
137
|
+
@override
|
|
138
|
+
State<PhotoGallery> createState() => _PhotoGalleryState();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
class _PhotoGalleryState extends State<PhotoGallery> {
|
|
142
|
+
late Future<List<Photo>> _futurePhotos;
|
|
143
|
+
|
|
144
|
+
@override
|
|
145
|
+
void initState() {
|
|
146
|
+
super.initState();
|
|
147
|
+
// Initialize Future once to prevent re-fetching on rebuilds
|
|
148
|
+
_futurePhotos = fetchPhotos();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
@override
|
|
152
|
+
Widget build(BuildContext context) {
|
|
153
|
+
return FutureBuilder<List<Photo>>(
|
|
154
|
+
future: _futurePhotos,
|
|
155
|
+
builder: (context, snapshot) {
|
|
156
|
+
if (snapshot.hasData) {
|
|
157
|
+
final photos = snapshot.data!;
|
|
158
|
+
return ListView.builder(
|
|
159
|
+
itemCount: photos.length,
|
|
160
|
+
itemBuilder: (context, index) => ListTile(
|
|
161
|
+
leading: Image.network(photos[index].thumbnailUrl),
|
|
162
|
+
title: Text(photos[index].title),
|
|
163
|
+
),
|
|
164
|
+
);
|
|
165
|
+
} else if (snapshot.hasError) {
|
|
166
|
+
return Center(child: Text('Error: ${snapshot.error}'));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Default loading state
|
|
170
|
+
return const Center(child: CircularProgressIndicator());
|
|
171
|
+
},
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
```
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: add-dart-lint-validation-rule
|
|
3
|
+
description: Instructions for adding a new validation rule and CLI flag to dart_skills_lint.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Add a New Validation Rule and Flag
|
|
7
|
+
|
|
8
|
+
Use this skill when you need to add a new validation rule to the `dart_skills_lint` package, expose it as a toggleable CLI flag, and verify its behavior.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## 🛠️ Step-by-Step Implementation
|
|
13
|
+
|
|
14
|
+
### 1. Create the Rule Class
|
|
15
|
+
Create a new file in `lib/src/rules/` extending `SkillRule`.
|
|
16
|
+
|
|
17
|
+
> [!TIP]
|
|
18
|
+
> If your rule expects a specific structure in the skill's YAML frontmatter (e.g., inside `metadata`), document this structure clearly in the class Dart docstring.
|
|
19
|
+
|
|
20
|
+
```dart
|
|
21
|
+
// lib/src/rules/my_new_rule.dart
|
|
22
|
+
|
|
23
|
+
import '../models/analysis_severity.dart';
|
|
24
|
+
import '../models/skill_context.dart';
|
|
25
|
+
import '../models/skill_rule.dart';
|
|
26
|
+
import '../models/validation_error.dart';
|
|
27
|
+
|
|
28
|
+
class MyNewRule extends SkillRule {
|
|
29
|
+
MyNewRule({super.severity});
|
|
30
|
+
|
|
31
|
+
@override
|
|
32
|
+
Future<List<ValidationError>> validate(SkillContext context) async {
|
|
33
|
+
final errors = <ValidationError>[];
|
|
34
|
+
// Add validation logic here using context.rawContent or context.directory
|
|
35
|
+
return errors;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
#### Accessing YAML Frontmatter
|
|
41
|
+
If your rule needs configuration from the skill's YAML frontmatter, you can access it via `context.parsedYaml`.
|
|
42
|
+
|
|
43
|
+
```dart
|
|
44
|
+
@override
|
|
45
|
+
Future<List<ValidationError>> validate(SkillContext context) async {
|
|
46
|
+
final errors = <ValidationError>[];
|
|
47
|
+
final yaml = context.parsedYaml;
|
|
48
|
+
if (yaml != null) {
|
|
49
|
+
final metadata = yaml['metadata'];
|
|
50
|
+
if (metadata is Map) {
|
|
51
|
+
// Read your custom config here
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return errors;
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 2. Register the Rule in `lib/src/rule_registry.dart`
|
|
59
|
+
|
|
60
|
+
Add a new `CheckType` instance to `RuleRegistry.allChecks` list. This automatically exposes it as a CLI flag.
|
|
61
|
+
|
|
62
|
+
```dart
|
|
63
|
+
// lib/src/rule_registry.dart in allChecks list
|
|
64
|
+
|
|
65
|
+
const CheckType(
|
|
66
|
+
name: MyNewRule.ruleName,
|
|
67
|
+
defaultSeverity: MyNewRule.defaultSeverity,
|
|
68
|
+
help: 'Description of what the rule does for CLI help.',
|
|
69
|
+
),
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Then, add a case to `RuleRegistry.createRule` to instantiate your rule:
|
|
73
|
+
|
|
74
|
+
```dart
|
|
75
|
+
// lib/src/rule_registry.dart in createRule method
|
|
76
|
+
|
|
77
|
+
static SkillRule? createRule(String name, AnalysisSeverity severity) {
|
|
78
|
+
switch (name) {
|
|
79
|
+
// ... other rules
|
|
80
|
+
case MyNewRule.ruleName:
|
|
81
|
+
return MyNewRule(severity: severity);
|
|
82
|
+
default:
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 3. Handle Disabled by Default Rules (If applicable)
|
|
89
|
+
If the rule is disabled by default (`defaultSeverity: AnalysisSeverity.disabled`), passing the flag `--check-my-new-rule` will automatically enable it with `AnalysisSeverity.error` severity (handled in `entry_point.dart`).
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## 🧪 Testing the New Rule
|
|
94
|
+
|
|
95
|
+
You must write automated tests verifying your rule triggers when it should and skips when it shouldn't.
|
|
96
|
+
|
|
97
|
+
### Preferred Approach: In-Memory Unit Tests
|
|
98
|
+
Instead of writing files to disk, test the rule directly using a mock `SkillContext`. This is faster and avoids I/O dependencies.
|
|
99
|
+
|
|
100
|
+
```dart
|
|
101
|
+
// test/my_new_rule_test.dart
|
|
102
|
+
|
|
103
|
+
import 'dart:io';
|
|
104
|
+
import 'package:dart_skills_lint/src/models/analysis_severity.dart';
|
|
105
|
+
import 'package:dart_skills_lint/src/models/skill_context.dart';
|
|
106
|
+
import 'package:dart_skills_lint/src/models/validation_error.dart';
|
|
107
|
+
import 'package:dart_skills_lint/src/rules/my_new_rule.dart';
|
|
108
|
+
import 'package:test/test.dart';
|
|
109
|
+
|
|
110
|
+
void main() {
|
|
111
|
+
group('MyNewRule', () {
|
|
112
|
+
test('flags invalid content', () async {
|
|
113
|
+
final rule = MyNewRule(severity: AnalysisSeverity.warning);
|
|
114
|
+
final context = SkillContext(
|
|
115
|
+
directory: Directory('dummy'),
|
|
116
|
+
rawContent: 'Invalid content',
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
final List<ValidationError> errors = await rule.validate(context);
|
|
120
|
+
|
|
121
|
+
expect(errors, isNotEmpty);
|
|
122
|
+
expect(errors.first.message, contains('Expected error message'));
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
test('passes valid content', () async {
|
|
126
|
+
final rule = MyNewRule(severity: AnalysisSeverity.warning);
|
|
127
|
+
final context = SkillContext(
|
|
128
|
+
directory: Directory('dummy'),
|
|
129
|
+
rawContent: 'Valid content',
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
final List<ValidationError> errors = await rule.validate(context);
|
|
133
|
+
|
|
134
|
+
expect(errors, isEmpty);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Alternative Approach: File System Interaction
|
|
141
|
+
If the rule interacts with the file system or wraps an external CLI tool (like `popmark`), you should use a temporary directory for testing instead of in-memory mocks.
|
|
142
|
+
|
|
143
|
+
```dart
|
|
144
|
+
late Directory tempDir;
|
|
145
|
+
|
|
146
|
+
setUp(() async {
|
|
147
|
+
tempDir = await Directory.systemTemp.createTemp('my_rule_test.');
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
tearDown(() async {
|
|
151
|
+
if (tempDir.existsSync()) {
|
|
152
|
+
await tempDir.delete(recursive: true);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test('flags invalid file content', () async {
|
|
157
|
+
final Directory skillDir = await Directory('${tempDir.path}/test-skill').create();
|
|
158
|
+
await File('${skillDir.path}/SKILL.md').writeAsString('Invalid content');
|
|
159
|
+
|
|
160
|
+
final rule = MyNewRule(severity: AnalysisSeverity.warning);
|
|
161
|
+
final context = SkillContext(directory: skillDir, rawContent: 'Invalid content');
|
|
162
|
+
|
|
163
|
+
final List<ValidationError> errors = await rule.validate(context);
|
|
164
|
+
|
|
165
|
+
expect(errors, isNotEmpty);
|
|
166
|
+
});
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Integration Tests
|
|
170
|
+
If the rule interacts with CLI flags or configuration files, add a test in `test/cli_integration_test.dart` using `TestProcess`.
|
|
171
|
+
> [!IMPORTANT]
|
|
172
|
+
> When writing integration tests that use config files and `TestProcess`, ensure that paths in the config file and paths passed to the CLI match in style (both relative or both absolute) to avoid issues with path matching in `entry_point.dart`.
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
176
|
+
## 📚 Documentation Updates
|
|
177
|
+
|
|
178
|
+
When a new rule is introduced, verify that you synchronize sibling markdown files!
|
|
179
|
+
|
|
180
|
+
1. **`README.md`:**
|
|
181
|
+
* Add your flag under the **Usage** and **Flags** sections so users know it exists.
|
|
182
|
+
2. **`documentation/knowledge/SPECIFICATION.md`:**
|
|
183
|
+
* Document the formal constraint in the specification if it defines a standard for skill files.
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## 🚦 Checklist Before Submitting PR
|
|
188
|
+
|
|
189
|
+
- [ ] Rule class created in `lib/src/rules/`.
|
|
190
|
+
- [ ] Rule registered in `lib/src/rule_registry.dart`.
|
|
191
|
+
- [ ] Unit tests added in `test/` using in-memory `SkillContext`.
|
|
192
|
+
- [ ] Usage listed in `README.md`.
|
|
193
|
+
- [ ] Schema documented in `documentation/knowledge/SPECIFICATION.md` (if applicable).
|
|
194
|
+
- [ ] Run `dart format .` to format code.
|
|
195
|
+
- [ ] Run `dart analyze --fatal-infos` to ensure no issues.
|
|
196
|
+
- [ ] Run `dart test` to ensure tests passing.
|
package/skills/flutter-skills/tool/dart_skills_lint/.agents/skills/dart-best-practices/SKILL.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dart-best-practices
|
|
3
|
+
description: |-
|
|
4
|
+
General best practices for Dart development.
|
|
5
|
+
Covers code style, effective Dart, and language features.
|
|
6
|
+
license: Apache-2.0
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Dart Best Practices
|
|
10
|
+
|
|
11
|
+
## 1. When to use this skill
|
|
12
|
+
Use this skill when:
|
|
13
|
+
- Writing or reviewing Dart code.
|
|
14
|
+
- Looking for guidance on idiomatic Dart usage.
|
|
15
|
+
|
|
16
|
+
## 2. Best Practices
|
|
17
|
+
|
|
18
|
+
### Multi-line Strings
|
|
19
|
+
Prefer using multi-line strings (`'''`) over concatenating strings with `+` and
|
|
20
|
+
`\n`, especially for large blocks of text like SQL queries, HTML, or
|
|
21
|
+
PEM-encoded keys. This improves readability and avoids
|
|
22
|
+
`lines_longer_than_80_chars` lint errors by allowing natural line breaks.
|
|
23
|
+
|
|
24
|
+
**Avoid:**
|
|
25
|
+
```dart
|
|
26
|
+
final pem = '-----BEGIN RSA PRIVATE KEY-----\n' +
|
|
27
|
+
base64Encode(fullBytes) +
|
|
28
|
+
'\n-----END RSA PRIVATE KEY-----';
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**Prefer:**
|
|
32
|
+
```dart
|
|
33
|
+
final pem = '''
|
|
34
|
+
-----BEGIN RSA PRIVATE KEY-----
|
|
35
|
+
${base64Encode(fullBytes)}
|
|
36
|
+
-----END RSA PRIVATE KEY-----''';
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Line Length
|
|
40
|
+
Avoid lines longer than 80 characters, even in Markdown files and comments.
|
|
41
|
+
This ensures code is readable in split-screen views and on smaller screens
|
|
42
|
+
without horizontal scrolling.
|
|
43
|
+
|
|
44
|
+
**Prefer:**
|
|
45
|
+
Target 80 characters for wrapping text. Exceptions are allowed for long URLs
|
|
46
|
+
or identifiers that cannot be broken.
|
|
47
|
+
|
|
48
|
+
## Discovery
|
|
49
|
+
|
|
50
|
+
### Multi-line Strings
|
|
51
|
+
To find candidates for multi-line strings, search for string concatenation
|
|
52
|
+
with `+` involving newlines:
|
|
53
|
+
- **Regex**: `['"]\s*\+\s*['"]`
|
|
54
|
+
- **Regex**: `\+\s*['"].*\\n`
|
|
55
|
+
|
|
56
|
+
### Line Length
|
|
57
|
+
- Rely on the `lines_longer_than_80_chars` lint from the analyzer.
|
|
58
|
+
|
|
59
|
+
## Related Skills
|
|
60
|
+
|
|
61
|
+
- **[dart-modern-features]**: For idiomatic
|
|
62
|
+
usage of modern Dart features like Pattern Matching (useful for deep JSON
|
|
63
|
+
extraction), Records, and Switch Expressions.
|
|
64
|
+
|
|
65
|
+
[dart-modern-features]: https://github.com/kevmoo/dash_skills/blob/main/.agent/skills/dart-modern-features/SKILL.md
|