enghany301096/hany-skills/flutter-use-http-package
Claude Code and agent skill by enghany301096/hany-skills
- community
Checking that the SKILL.md file is still in the repository.
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.
Install
npx vskill@latest install enghany301096/hany-skills/flutter-use-http-packageSKILL.md
The same SKILL.md was published earlier as flutter/skills/flutter-use-http-package.
Implementing Flutter Networking
Contents
- Configuration & Permissions
- Request Execution & Response Handling
- Background Parsing
- Workflow: Executing Network Operations
- Examples
Configuration & Permissions
Configure the environment and platform-specific permissions required for network access.
- Add the
httppackage dependency via the terminal:
``bash flutter pub add http ``
- Import the package in your Dart files:
``dart import 'package:http/http.dart' as http; ``
- Configure Android permissions by adding the Internet permission to
android/app/src/main/AndroidManifest.xml:
``xml <uses-permission android:name="android.permission.INTERNET" /> ``
- Configure macOS entitlements by adding the network client key to both
macos/Runner/DebugProfile.entitlementsandmacos/Runner/Release.entitlements:
``xml <key>com.apple.security.network.client</key> <true/> ``
Request Execution & Response Handling
Execute HTTP operations and map responses to strongly typed Dart objects.
- URIs: Always parse URL strings using
Uri.parse('your_url'). - Headers: Inject authorization and content-type headers via the
headersparameter map. UseHttpHeaders.authorizationHeaderfor auth tokens. - Payloads: For POST and PUT requests, encode the body using
jsonEncode()fromdart:convert. - Status Validation: Evaluate
response.statusCode. Treat200 OK(GET/PUT/DELETE) and201 CREATED(POST) as success. - Error Handling: Throw explicit exceptions for non-success status codes. Never return
nullon failure, as this preventsFutureBuilderfrom triggering its error state and causes infinite loading indicators. - Deserialization: Parse the raw string using
jsonDecode(response.body)and map it to a custom Dart object using a factory constructor (e.g.,fromJson).
Background Parsing
Offload expensive JSON parsing to a separate Isolate to prevent UI jank (frame drops).
- Import
package:flutter/foundation.dart. - Use the
compute()function to run the parsing logic in a background isolate. - 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.
Workflow: Executing Network Operations
Use the following checklist to implement and validate network operations.
Task Progress:
- [ ] 1. Define the strongly typed Dart model with a
fromJsonfactory constructor. - [ ] 2. Implement the network request method returning a
Future<Model>. - [ ] 3. Apply conditional logic based on the operation type:
- If fetching data (GET): Append query parameters to the URI.
- If mutating data (POST/PUT): Set
'Content-Type': 'application/json; charset=UTF-8'and attach thejsonEncodebody. - If deleting data (DELETE): Return an empty model instance on success (
200 OK). - [ ] 4. Validate the
statusCodeand throw anExceptionon failure. - [ ] 5. Integrate the
Futureinto the UI usingFutureBuilder. - [ ] 6. Handle
snapshot.hasData,snapshot.hasError, and default to aCircularProgressIndicator. - [ ] 7. Feedback Loop: Run the app -> trigger the network request -> review console for unhandled exceptions -> fix parsing or permission errors.
Examples
High-Fidelity Implementation: Fetching and Parsing in the Background
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingflutter/flutter-use-http-package/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/enghany301096/hany-skills/flutter-use-http-package)