[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7BVAFR697XWD4G2JEDZ6JZ5":3,"skill-same:01M7BVAFR697XWD4G2JEDZ6JZ5":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},"01M7BVAFR697XWD4G2JEDZ6JZ5","flutter-use-http-package",null,"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.","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\u002Fflutter-use-http-package\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: flutter-use-http-package\ndescription: 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.\nmetadata:\n  model: models\u002Fgemini-3.1-pro-preview\n  last_modified: Tue, 21 Apr 2026 21:36:42 GMT\n---\n# Implementing Flutter Networking\n\n## Contents\n- [Configuration & Permissions](#configuration--permissions)\n- [Request Execution & Response Handling](#request-execution--response-handling)\n- [Background Parsing](#background-parsing)\n- [Workflow: Executing Network Operations](#workflow-executing-network-operations)\n- [Examples](#examples)\n\n## Configuration & Permissions\n\nConfigure the environment and platform-specific permissions required for network access.\n\n1. Add the `http` package dependency via the terminal:\n   ```bash\n   flutter pub add http\n   ```\n2. Import the package in your Dart files:\n   ```dart\n   import 'package:http\u002Fhttp.dart' as http;\n   ```\n3. Configure Android permissions by adding the Internet permission to `android\u002Fapp\u002Fsrc\u002Fmain\u002FAndroidManifest.xml`:\n   ```xml\n   \u003Cuses-permission android:name=\"android.permission.INTERNET\" \u002F>\n   ```\n4. Configure macOS entitlements by adding the network client key to both `macos\u002FRunner\u002FDebugProfile.entitlements` and `macos\u002FRunner\u002FRelease.entitlements`:\n   ```xml\n   \u003Ckey>com.apple.security.network.client\u003C\u002Fkey>\n   \u003Ctrue\u002F>\n   ```\n\n## Request Execution & Response Handling\n\nExecute HTTP operations and map responses to strongly typed Dart objects.\n\n*   **URIs:** Always parse URL strings using `Uri.parse('your_url')`.\n*   **Headers:** Inject authorization and content-type headers via the `headers` parameter map. Use `HttpHeaders.authorizationHeader` for auth tokens.\n*   **Payloads:** For POST and PUT requests, encode the body using `jsonEncode()` from `dart:convert`.\n*   **Status Validation:** Evaluate `response.statusCode`. Treat `200 OK` (GET\u002FPUT\u002FDELETE) and `201 CREATED` (POST) as success. \n*   **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.\n*   **Deserialization:** Parse the raw string using `jsonDecode(response.body)` and map it to a custom Dart object using a factory constructor (e.g., `fromJson`).\n\n## Background Parsing\n\nOffload expensive JSON parsing to a separate Isolate to prevent UI jank (frame drops).\n\n*   Import `package:flutter\u002Ffoundation.dart`.\n*   Use the `compute()` function to run the parsing logic in a background isolate.\n*   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.\n\n## Workflow: Executing Network Operations\n\nUse the following checklist to implement and validate network operations.\n\n**Task Progress:**\n- [ ] 1. Define the strongly typed Dart model with a `fromJson` factory constructor.\n- [ ] 2. Implement the network request method returning a `Future\u003CModel>`.\n- [ ] 3. Apply conditional logic based on the operation type:\n  - **If fetching data (GET):** Append query parameters to the URI.\n  - **If mutating data (POST\u002FPUT):** Set `'Content-Type': 'application\u002Fjson; charset=UTF-8'` and attach the `jsonEncode` body.\n  - **If deleting data (DELETE):** Return an empty model instance on success (`200 OK`).\n- [ ] 4. Validate the `statusCode` and throw an `Exception` on failure.\n- [ ] 5. Integrate the `Future` into the UI using `FutureBuilder`.\n- [ ] 6. Handle `snapshot.hasData`, `snapshot.hasError`, and default to a `CircularProgressIndicator`.\n- [ ] 7. **Feedback Loop:** Run the app -> trigger the network request -> review console for unhandled exceptions -> fix parsing or permission errors.\n\n## Examples\n\n### High-Fidelity Implementation: Fetching and Parsing in the Background\n\n```dart\nimport 'dart:async';\nimport 'dart:convert';\nimport 'dart:io';\nimport 'package:flutter\u002Ffoundation.dart';\nimport 'package:flutter\u002Fmaterial.dart';\nimport 'package:http\u002Fhttp.dart' as http;\n\n\u002F\u002F 1. Top-level parsing function for Isolate\nList\u003CPhoto> parsePhotos(String responseBody) {\n  final parsed = (jsonDecode(responseBody) as List\u003CObject?>)\n      .cast\u003CMap\u003CString, Object?>>();\n  return parsed.map\u003CPhoto>(Photo.fromJson).toList();\n}\n\n\u002F\u002F 2. Network execution with background parsing\nFuture\u003CList\u003CPhoto>> fetchPhotos() async {\n  final response = await http.get(\n    Uri.parse('https:\u002F\u002Fjsonplaceholder.typicode.com\u002Fphotos'),\n    headers: {\n      HttpHeaders.authorizationHeader: 'Bearer your_token_here',\n      HttpHeaders.acceptHeader: 'application\u002Fjson',\n    },\n  );\n\n  if (response.statusCode == 200) {\n    \u002F\u002F Offload heavy parsing to a background isolate\n    return compute(parsePhotos, response.body);\n  } else {\n    throw Exception('Failed to load photos. Status: ${response.statusCode}');\n  }\n}\n\n\u002F\u002F 3. Strongly typed model\nclass Photo {\n  final int id;\n  final String title;\n  final String thumbnailUrl;\n\n  const Photo({\n    required this.id,\n    required this.title,\n    required this.thumbnailUrl,\n  });\n\n  factory Photo.fromJson(Map\u003CString, dynamic> json) {\n    return Photo(\n      id: json['id'] as int,\n      title: json['title'] as String,\n      thumbnailUrl: json['thumbnailUrl'] as String,\n    );\n  }\n}\n\n\u002F\u002F 4. UI Integration\nclass PhotoGallery extends StatefulWidget {\n  const PhotoGallery({super.key});\n\n  @override\n  State\u003CPhotoGallery> createState() => _PhotoGalleryState();\n}\n\nclass _PhotoGalleryState extends State\u003CPhotoGallery> {\n  late Future\u003CList\u003CPhoto>> _futurePhotos;\n\n  @override\n  void initState() {\n    super.initState();\n    \u002F\u002F Initialize Future once to prevent re-fetching on rebuilds\n    _futurePhotos = fetchPhotos();\n  }\n\n  @override\n  Widget build(BuildContext context) {\n    return FutureBuilder\u003CList\u003CPhoto>>(\n      future: _futurePhotos,\n      builder: (context, snapshot) {\n        if (snapshot.hasData) {\n          final photos = snapshot.data!;\n          return ListView.builder(\n            itemCount: photos.length,\n            itemBuilder: (context, index) => ListTile(\n              leading: Image.network(photos[index].thumbnailUrl),\n              title: Text(photos[index].title),\n            ),\n          );\n        } else if (snapshot.hasError) {\n          return Center(child: Text('Error: ${snapshot.error}'));\n        }\n        \n        \u002F\u002F Default loading state\n        return const Center(child: CircularProgressIndicator());\n      },\n    );\n  }\n}\n```\n","# Implementing Flutter Networking\n\n## Contents\n- [Configuration & Permissions](#configuration--permissions)\n- [Request Execution & Response Handling](#request-execution--response-handling)\n- [Background Parsing](#background-parsing)\n- [Workflow: Executing Network Operations](#workflow-executing-network-operations)\n- [Examples](#examples)\n\n## Configuration & Permissions\n\nConfigure the environment and platform-specific permissions required for network access.\n\n1. Add the `http` package dependency via the terminal:\n   ```bash\n   flutter pub add http\n   ```\n2. Import the package in your Dart files:\n   ```dart\n   import 'package:http\u002Fhttp.dart' as http;\n   ```\n3. Configure Android permissions by adding the Internet permission to `android\u002Fapp\u002Fsrc\u002Fmain\u002FAndroidManifest.xml`:\n   ```xml\n   \u003Cuses-permission android:name=\"android.permission.INTERNET\" \u002F>\n   ```\n4. Configure macOS entitlements by adding the network client key to both `macos\u002FRunner\u002FDebugProfile.entitlements` and `macos\u002FRunner\u002FRelease.entitlements`:\n   ```xml\n   \u003Ckey>com.apple.security.network.client\u003C\u002Fkey>\n   \u003Ctrue\u002F>\n   ```\n\n## Request Execution & Response Handling\n\nExecute HTTP operations and map responses to strongly typed Dart objects.\n\n*   **URIs:** Always parse URL strings using `Uri.parse('your_url')`.\n*   **Headers:** Inject authorization and content-type headers via the `headers` parameter map. Use `HttpHeaders.authorizationHeader` for auth tokens.\n*   **Payloads:** For POST and PUT requests, encode the body using `jsonEncode()` from `dart:convert`.\n*   **Status Validation:** Evaluate `response.statusCode`. Treat `200 OK` (GET\u002FPUT\u002FDELETE) and `201 CREATED` (POST) as success. \n*   **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.\n*   **Deserialization:** Parse the raw string using `jsonDecode(response.body)` and map it to a custom Dart object using a factory constructor (e.g., `fromJson`).\n\n## Background Parsing\n\nOffload expensive JSON parsing to a separate Isolate to prevent UI jank (frame drops).\n\n*   Import `package:flutter\u002Ffoundation.dart`.\n*   Use the `compute()` function to run the parsing logic in a background isolate.\n*   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.\n\n## Workflow: Executing Network Operations\n\nUse the following checklist to implement and validate network operations.\n\n**Task Progress:**\n- [ ] 1. Define the strongly typed Dart model with a `fromJson` factory constructor.\n- [ ] 2. Implement the network request method returning a `Future\u003CModel>`.\n- [ ] 3. Apply conditional logic based on the operation type:\n  - **If fetching data (GET):** Append query parameters to the URI.\n  - **If mutating data (POST\u002FPUT):** Set `'Content-Type': 'application\u002Fjson; charset=UTF-8'` and attach the `jsonEncode` body.\n  - **If deleting data (DELETE):** Return an empty model instance on success (`200 OK`).\n- [ ] 4. Validate the `statusCode` and throw an `Exception` on failure.\n- [ ] 5. Integrate the `Future` into the UI using `FutureBuilder`.\n- [ ] 6. Handle `snapshot.hasData`, `snapshot.hasError`, and default to a `CircularProgressIndicator`.\n- [ ] 7. **Feedback Loop:** Run the app -> trigger the network request -> review console for unhandled exceptions -> fix parsing or permission errors.\n\n## Examples\n\n### High-Fidelity Implementation: Fetching and Parsing in the Background\n\n```dart\nimport 'dart:async';\nimport 'dart:convert';\nimport 'dart:io';\nimport 'package:flutter\u002Ffoundation.dart';\nimport 'package:flutter\u002Fmaterial.dart';\nimport 'package:http\u002Fhttp.dart' as http;\n\n\u002F\u002F 1. Top-level parsing function for Isolate\nList\u003CPhoto> parsePhotos(String responseBody) {\n  final parsed = (jsonDecode(responseBody) as List\u003CObject?>)\n      .cast\u003CMap\u003CString, Object?>>();\n  return parsed.map\u003CPhoto>(Photo.fromJson).toList();\n}\n\n\u002F\u002F 2. Network execution with background parsing\nFuture\u003CList\u003CPhoto>> fetchPhotos() async {\n  final response = await http.get(\n    Uri.parse('https:\u002F\u002Fjsonplaceholder.typicode.com\u002Fphotos'),\n    headers: {\n      HttpHeaders.authorizationHeader: 'Bearer your_token_here',\n      HttpHeaders.acceptHeader: 'application\u002Fjson',\n    },\n  );\n\n  if (response.statusCode == 200) {\n    \u002F\u002F Offload heavy parsing to a background isolate\n    return compute(parsePhotos, response.body);\n  } else {\n    throw Exception('Failed to load photos. Status: ${response.statusCode}');\n  }\n}\n\n\u002F\u002F 3. Strongly typed model\nclass Photo {\n  final int id;\n  final String title;\n  final String thumbnailUrl;\n\n  const Photo({\n    required this.id,\n    required this.title,\n    required this.thumbnailUrl,\n  });\n\n  factory Photo.fromJson(Map\u003CString, dynamic> json) {\n    return Photo(\n      id: json['id'] as int,\n      title: json['title'] as String,\n      thumbnailUrl: json['thumbnailUrl'] as String,\n    );\n  }\n}\n\n\u002F\u002F 4. UI Integration\nclass PhotoGallery extends StatefulWidget {\n  const PhotoGallery({super.key});\n\n  @override\n  State\u003CPhotoGallery> createState() => _PhotoGalleryState();\n}\n\nclass _PhotoGalleryState extends State\u003CPhotoGallery> {\n  late Future\u003CList\u003CPhoto>> _futurePhotos;\n\n  @override\n  void initState() {\n    super.initState();\n    \u002F\u002F Initialize Future once to prevent re-fetching on rebuilds\n    _futurePhotos = fetchPhotos();\n  }\n\n  @override\n  Widget build(BuildContext context) {\n    return FutureBuilder\u003CList\u003CPhoto>>(\n      future: _futurePhotos,\n      builder: (context, snapshot) {\n        if (snapshot.hasData) {\n          final photos = snapshot.data!;\n          return ListView.builder(\n            itemCount: photos.length,\n            itemBuilder: (context, index) => ListTile(\n              leading: Image.network(photos[index].thumbnailUrl),\n              title: Text(photos[index].title),\n            ),\n          );\n        } else if (snapshot.hasError) {\n          return Center(child: Text('Error: ${snapshot.error}'));\n        }\n        \n        \u002F\u002F Default loading state\n        return const Center(child: CircularProgressIndicator());\n      },\n    );\n  }\n}\n```\n",{"name":5,"metadata":23,"description":7},{"model":24,"last_modified":25},"models\u002Fgemini-3.1-pro-preview","Tue, 21 Apr 2026 21:36:42 GMT","main","900ea3c9eb045fd5b0317dc1103777ecf3ea4aeb","skills\u002Fflutter-use-http-package",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 flutter-use-http-package",{"tool":40,"command":41},"bunx","bunx skills add nguyenhungtran18\u002Fskill-and-tool-tracker --skill flutter-use-http-package",{"tool":43,"command":44},"pnpm","pnpm dlx skills add nguyenhungtran18\u002Fskill-and-tool-tracker --skill flutter-use-http-package","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fnguyenhungtran18\u002Fskill-and-tool-tracker\u002Fblob\u002Fmain\u002Fskills\u002Fflutter-use-http-package\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",[],[]]