[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7BV4XP2DPZ249DZ45C7CM3Y":3,"skill-same:01M7BV4XP2DPZ249DZ45C7CM3Y":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":26,"commitSha":27,"skillDirectory":28,"forksCount":29,"repositoryHtmlUrl":30,"repositoryHomepageUrl":31,"ownerHtmlUrl":32,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":33,"install":34,"resources":47},"01M7BV4XP2DPZ249DZ45C7CM3Y","dart-fix-runtime-errors",null,"Uses get_runtime_errors and lsp to fetch an active stack trace, locate the failing line, apply a fix, and verify resolution via hot_reload.","nguyenhungtran18\u002Fskill-and-tool-tracker","nguyenhungtran18","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F297063550?v=4","01M7BV0BFPRRFP84F2ME0FYZ9D","01M7BV0BG83FA5P22NJV0GR0A5",1,"MIT","https:\u002F\u002Fgithub.com\u002Fnguyenhungtran18\u002Fskill-and-tool-tracker\u002Fblob\u002Fmain\u002Fskills\u002Fdart-fix-runtime-errors\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: dart-fix-runtime-errors\ndescription: Uses get_runtime_errors and lsp to fetch an active stack trace, locate the failing line, apply a fix, and verify resolution via hot_reload.\nmetadata:\n  model: models\u002Fgemini-3.1-pro-preview\n  last_modified: Fri, 24 Apr 2026 15:13:22 GMT\n---\n# Resolving Dart Static Analysis Errors\n\n## Contents\n- [Core Concepts & Guidelines](#core-concepts--guidelines)\n  - [Type System & Soundness](#type-system--soundness)\n  - [Null Safety](#null-safety)\n  - [Error Handling](#error-handling)\n- [Workflows](#workflows)\n  - [Workflow: Static Analysis Resolution](#workflow-static-analysis-resolution)\n- [Examples](#examples)\n\n## Core Concepts & Guidelines\n\n### Type System & Soundness\nEnforce Dart's sound type system to prevent runtime invalid states.\n\n*   **Method Overrides:** Maintain sound return types (covariant) and parameter types (contravariant). Never tighten a parameter type in a subclass unless explicitly marked with the `covariant` keyword.\n*   **Generics & Collections:** Add explicit type annotations to generic classes (e.g., `List\u003CT>`, `Map\u003CK, V>`). Never assign a `List\u003Cdynamic>` to a typed list (e.g., `List\u003CCat>`).\n*   **Downcasting:** Avoid implicit downcasts from `dynamic`. Use explicit casts (e.g., `as List\u003CCat>`) when necessary, but ensure the underlying runtime type matches to prevent `TypeError` exceptions.\n*   **Strict Casts:** Enable `strict-casts: true` in `analysis_options.yaml` under `analyzer: language:` to force explicit casting and catch implicit downcast errors at compile time.\n\n### Null Safety\nEliminate static errors related to null safety by correctly managing variable initialization and nullability.\n\n*   **Modifiers:** Apply `?` for nullable types, `!` for null assertions, and `required` for named parameters that cannot be null.\n*   **Late Initialization:** Use the `late` keyword for non-nullable variables guaranteed to be initialized before use. Apply this specifically to top-level or instance variables where Dart's control flow analysis cannot definitively prove initialization.\n*   **Wildcards:** Use the `_` wildcard variable (Dart 3.7+) for non-binding local variables or parameters to avoid unused variable warnings.\n\n### Error Handling\nDistinguish between recoverable exceptions and unrecoverable errors.\n\n*   **Catching:** Catch `Exception` subtypes for recoverable failures.\n*   **Errors:** Never explicitly catch `Error` or its subtypes (e.g., `TypeError`, `ArgumentError`). Errors indicate programming bugs that must be fixed, not caught. Enforce this by enabling the `avoid_catching_errors` linter rule.\n*   **Rethrowing:** Use `rethrow` inside a `catch` block to propagate an exception while preserving its original stack trace.\n\n## Workflows\n\n### Workflow: Static Analysis Resolution\n\nUse this sequential workflow to identify, fix, and verify static analysis errors in a Dart project. Copy the checklist to track your progress.\n\n**Task Progress:**\n- [ ] 1. Run static analyzer.\n- [ ] 2. Apply automated fixes.\n- [ ] 3. Resolve remaining errors manually.\n- [ ] 4. Verify fixes (Feedback Loop).\n\n**1. Run static analyzer**\nExecute the Dart analyzer to identify all static errors in the target directory or file.\n```bash\ndart analyze . --fatal-infos\n```\n\n**2. Apply automated fixes**\nUse the `dart fix` tool to automatically resolve standard linting and analysis issues.\n```bash\n# Preview changes\ndart fix --dry-run\n# Apply changes\ndart fix --apply\n```\n\n**3. Resolve remaining errors manually**\nReview the remaining analyzer output and apply conditional logic based on the error type:\n\n*   **If the error is a Null Safety issue (e.g., \"Property cannot be accessed on a nullable receiver\"):**\n    *   Verify if the variable can logically be null.\n    *   If yes, use optional chaining (`?.`) or provide a fallback (`??`).\n    *   If no, and initialization is guaranteed elsewhere, mark the declaration with `late`.\n*   **If the error is a Type Mismatch (e.g., \"The argument type 'List\u003Cdynamic>' can't be assigned...\"):**\n    *   Trace the variable's initialization.\n    *   Add explicit generic type annotations to the instantiation (e.g., `\u003Cint>[]` instead of `[]`).\n*   **If the error is an Invalid Override (e.g., \"The parameter type doesn't match the overridden method\"):**\n    *   Widen the parameter type to match the superclass, OR\n    *   Add the `covariant` keyword to the parameter if tightening the type is intentionally required by the domain logic.\n\n**4. Verify fixes (Feedback Loop)**\nRun the validator. Review errors. Fix.\n```bash\ndart analyze .\ndart test\n```\n*   **If `dart analyze` reports errors:** Return to Step 3.\n*   **If `dart test` fails with a `TypeError`:** You have introduced an invalid explicit cast (`as T`) or accessed an uninitialized `late` variable. Locate the runtime failure and correct the type hierarchy or initialization order.\n\n## Examples\n\n### Example: Fixing Dynamic List Assignments\n**Input (Fails Static Analysis):**\n```dart\nvoid printInts(List\u003Cint> a) => print(a);\n\nvoid main() {\n  final list = []; \u002F\u002F Inferred as List\u003Cdynamic>\n  list.add(1);\n  list.add(2);\n  printInts(list); \u002F\u002F Error: List\u003Cdynamic> can't be assigned to List\u003Cint>\n}\n```\n\n**Output (Passes Static Analysis):**\n```dart\nvoid printInts(List\u003Cint> a) => print(a);\n\nvoid main() {\n  final list = \u003Cint>[]; \u002F\u002F Explicitly typed\n  list.add(1);\n  list.add(2);\n  printInts(list);\n}\n```\n\n### Example: Fixing Method Overrides (Contravariance)\n**Input (Fails Static Analysis):**\n```dart\nclass Animal {\n  void chase(Animal a) {}\n}\n\nclass Cat extends Animal {\n  @override\n  void chase(Mouse a) {} \u002F\u002F Error: Tightening parameter type\n}\n```\n\n**Output (Passes Static Analysis):**\n```dart\nclass Animal {\n  void chase(Animal a) {}\n}\n\nclass Cat extends Animal {\n  @override\n  void chase(covariant Mouse a) {} \u002F\u002F Explicitly marked covariant\n}\n```\n\n### Example: Fixing Null Safety with `late`\n**Input (Fails Static Analysis):**\n```dart\nclass Thermometer {\n  String temperature; \u002F\u002F Error: Non-nullable instance field must be initialized\n\n  void read() {\n    temperature = '20C';\n  }\n}\n```\n\n**Output (Passes Static Analysis):**\n```dart\nclass Thermometer {\n  late String temperature; \u002F\u002F Defers initialization check to runtime\n\n  void read() {\n    temperature = '20C';\n  }\n}\n```\n","# Resolving Dart Static Analysis Errors\n\n## Contents\n- [Core Concepts & Guidelines](#core-concepts--guidelines)\n  - [Type System & Soundness](#type-system--soundness)\n  - [Null Safety](#null-safety)\n  - [Error Handling](#error-handling)\n- [Workflows](#workflows)\n  - [Workflow: Static Analysis Resolution](#workflow-static-analysis-resolution)\n- [Examples](#examples)\n\n## Core Concepts & Guidelines\n\n### Type System & Soundness\nEnforce Dart's sound type system to prevent runtime invalid states.\n\n*   **Method Overrides:** Maintain sound return types (covariant) and parameter types (contravariant). Never tighten a parameter type in a subclass unless explicitly marked with the `covariant` keyword.\n*   **Generics & Collections:** Add explicit type annotations to generic classes (e.g., `List\u003CT>`, `Map\u003CK, V>`). Never assign a `List\u003Cdynamic>` to a typed list (e.g., `List\u003CCat>`).\n*   **Downcasting:** Avoid implicit downcasts from `dynamic`. Use explicit casts (e.g., `as List\u003CCat>`) when necessary, but ensure the underlying runtime type matches to prevent `TypeError` exceptions.\n*   **Strict Casts:** Enable `strict-casts: true` in `analysis_options.yaml` under `analyzer: language:` to force explicit casting and catch implicit downcast errors at compile time.\n\n### Null Safety\nEliminate static errors related to null safety by correctly managing variable initialization and nullability.\n\n*   **Modifiers:** Apply `?` for nullable types, `!` for null assertions, and `required` for named parameters that cannot be null.\n*   **Late Initialization:** Use the `late` keyword for non-nullable variables guaranteed to be initialized before use. Apply this specifically to top-level or instance variables where Dart's control flow analysis cannot definitively prove initialization.\n*   **Wildcards:** Use the `_` wildcard variable (Dart 3.7+) for non-binding local variables or parameters to avoid unused variable warnings.\n\n### Error Handling\nDistinguish between recoverable exceptions and unrecoverable errors.\n\n*   **Catching:** Catch `Exception` subtypes for recoverable failures.\n*   **Errors:** Never explicitly catch `Error` or its subtypes (e.g., `TypeError`, `ArgumentError`). Errors indicate programming bugs that must be fixed, not caught. Enforce this by enabling the `avoid_catching_errors` linter rule.\n*   **Rethrowing:** Use `rethrow` inside a `catch` block to propagate an exception while preserving its original stack trace.\n\n## Workflows\n\n### Workflow: Static Analysis Resolution\n\nUse this sequential workflow to identify, fix, and verify static analysis errors in a Dart project. Copy the checklist to track your progress.\n\n**Task Progress:**\n- [ ] 1. Run static analyzer.\n- [ ] 2. Apply automated fixes.\n- [ ] 3. Resolve remaining errors manually.\n- [ ] 4. Verify fixes (Feedback Loop).\n\n**1. Run static analyzer**\nExecute the Dart analyzer to identify all static errors in the target directory or file.\n```bash\ndart analyze . --fatal-infos\n```\n\n**2. Apply automated fixes**\nUse the `dart fix` tool to automatically resolve standard linting and analysis issues.\n```bash\n# Preview changes\ndart fix --dry-run\n# Apply changes\ndart fix --apply\n```\n\n**3. Resolve remaining errors manually**\nReview the remaining analyzer output and apply conditional logic based on the error type:\n\n*   **If the error is a Null Safety issue (e.g., \"Property cannot be accessed on a nullable receiver\"):**\n    *   Verify if the variable can logically be null.\n    *   If yes, use optional chaining (`?.`) or provide a fallback (`??`).\n    *   If no, and initialization is guaranteed elsewhere, mark the declaration with `late`.\n*   **If the error is a Type Mismatch (e.g., \"The argument type 'List\u003Cdynamic>' can't be assigned...\"):**\n    *   Trace the variable's initialization.\n    *   Add explicit generic type annotations to the instantiation (e.g., `\u003Cint>[]` instead of `[]`).\n*   **If the error is an Invalid Override (e.g., \"The parameter type doesn't match the overridden method\"):**\n    *   Widen the parameter type to match the superclass, OR\n    *   Add the `covariant` keyword to the parameter if tightening the type is intentionally required by the domain logic.\n\n**4. Verify fixes (Feedback Loop)**\nRun the validator. Review errors. Fix.\n```bash\ndart analyze .\ndart test\n```\n*   **If `dart analyze` reports errors:** Return to Step 3.\n*   **If `dart test` fails with a `TypeError`:** You have introduced an invalid explicit cast (`as T`) or accessed an uninitialized `late` variable. Locate the runtime failure and correct the type hierarchy or initialization order.\n\n## Examples\n\n### Example: Fixing Dynamic List Assignments\n**Input (Fails Static Analysis):**\n```dart\nvoid printInts(List\u003Cint> a) => print(a);\n\nvoid main() {\n  final list = []; \u002F\u002F Inferred as List\u003Cdynamic>\n  list.add(1);\n  list.add(2);\n  printInts(list); \u002F\u002F Error: List\u003Cdynamic> can't be assigned to List\u003Cint>\n}\n```\n\n**Output (Passes Static Analysis):**\n```dart\nvoid printInts(List\u003Cint> a) => print(a);\n\nvoid main() {\n  final list = \u003Cint>[]; \u002F\u002F Explicitly typed\n  list.add(1);\n  list.add(2);\n  printInts(list);\n}\n```\n\n### Example: Fixing Method Overrides (Contravariance)\n**Input (Fails Static Analysis):**\n```dart\nclass Animal {\n  void chase(Animal a) {}\n}\n\nclass Cat extends Animal {\n  @override\n  void chase(Mouse a) {} \u002F\u002F Error: Tightening parameter type\n}\n```\n\n**Output (Passes Static Analysis):**\n```dart\nclass Animal {\n  void chase(Animal a) {}\n}\n\nclass Cat extends Animal {\n  @override\n  void chase(covariant Mouse a) {} \u002F\u002F Explicitly marked covariant\n}\n```\n\n### Example: Fixing Null Safety with `late`\n**Input (Fails Static Analysis):**\n```dart\nclass Thermometer {\n  String temperature; \u002F\u002F Error: Non-nullable instance field must be initialized\n\n  void read() {\n    temperature = '20C';\n  }\n}\n```\n\n**Output (Passes Static Analysis):**\n```dart\nclass Thermometer {\n  late String temperature; \u002F\u002F Defers initialization check to runtime\n\n  void read() {\n    temperature = '20C';\n  }\n}\n```\n",{"name":5,"metadata":23,"description":7},{"model":24,"last_modified":25},"models\u002Fgemini-3.1-pro-preview","Fri, 24 Apr 2026 15:13:22 GMT","main","900ea3c9eb045fd5b0317dc1103777ecf3ea4aeb","skills\u002Fdart-fix-runtime-errors",0,"https:\u002F\u002Fgithub.com\u002Fnguyenhungtran18\u002Fskill-and-tool-tracker","https:\u002F\u002Fnguyenhungtran18.github.io\u002Fskill-and-tool-tracker\u002F","https:\u002F\u002Fgithub.com\u002Fnguyenhungtran18","2026-08-31 18:36:09",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add nguyenhungtran18\u002Fskill-and-tool-tracker --skill dart-fix-runtime-errors",{"tool":40,"command":41},"bunx","bunx skills add nguyenhungtran18\u002Fskill-and-tool-tracker --skill dart-fix-runtime-errors",{"tool":43,"command":44},"pnpm","pnpm dlx skills add nguyenhungtran18\u002Fskill-and-tool-tracker --skill dart-fix-runtime-errors","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fnguyenhungtran18\u002Fskill-and-tool-tracker\u002Fblob\u002Fmain\u002Fskills\u002Fdart-fix-runtime-errors\u002FSKILL.md",true,[],[49,56,63,70,77,84],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":18},"01M7BVP4P83TK60JZ4P8RP9VP7","xcode-project-setup","Safely modifies Xcode projects (.pbxproj) to add Swift Packages and link files. Use this skill whenever an iOS project needs dependencies installed (e.g. Firebase, Alamofire).","https:\u002F\u002Fgithub.com\u002Fnguyenhungtran18\u002Fskill-and-tool-tracker\u002Fblob\u002Fmain\u002Fskills\u002Fxcode_project_setup\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":18},"01M7BVP01K4CSJJ8G90FT8S2D5","writing-skills","Use when creating new skills, editing existing skills, or verifying skills work before deployment","https:\u002F\u002Fgithub.com\u002Fnguyenhungtran18\u002Fskill-and-tool-tracker\u002Fblob\u002Fmain\u002Fskills\u002Fwriting-skills\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":18},"01M7BVNY22GXD871GYTSH599F1","writing-plans","Use when you have a spec or requirements for a multi-step task, before touching code","https:\u002F\u002Fgithub.com\u002Fnguyenhungtran18\u002Fskill-and-tool-tracker\u002Fblob\u002Fmain\u002Fskills\u002Fwriting-plans\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":18},"01M7BVNQWF24RNKA8A4KM2HJ3T","workflow-skill-creator","Distills a completed user workflow or interaction into a reusable agent skill. Use when the user asks to turn their workflow, interaction, or multi-step process into a skill, or when they say \"make this a skill\", \"create a skill from what we just did\", \"package this workflow\" or similar. Do not use for creating skills from scratch without an existing workflow (use a generic skill-creator for that).","https:\u002F\u002Fgithub.com\u002Fnguyenhungtran18\u002Fskill-and-tool-tracker\u002Fblob\u002Fmain\u002Fskills\u002Fworkflow_skill_creator\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":18},"01M7BVNNY67XPCQAQHY3FBKDGC","verify-and-stop","Prove existing work meets acceptance conditions without expanding scope. Use for validation-only tasks, completion checks, focused gate runs, and last-mile proof.","https:\u002F\u002Fgithub.com\u002Fnguyenhungtran18\u002Fskill-and-tool-tracker\u002Fblob\u002Fmain\u002Fskills\u002Fverify-and-stop\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":18},"01M7BVNKB4Z7SZT85B73ZZ90Y6","verification-before-completion","Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always","https:\u002F\u002Fgithub.com\u002Fnguyenhungtran18\u002Fskill-and-tool-tracker\u002Fblob\u002Fmain\u002Fskills\u002Fverification-before-completion\u002FSKILL.md",[],[]]