flutter-handling-http-and-jsonlisted
Install: claude install-skill openplaybooks-dev/converge
# Handling HTTP and JSON
## Contents
- [Core Guidelines](#core-guidelines)
- [Workflow: Executing HTTP Operations](#workflow-executing-http-operations)
- [Workflow: Implementing JSON Serialization](#workflow-implementing-json-serialization)
- [Examples](#examples)
## Core Guidelines
- **Enforce HTTPS:** iOS and Android disable cleartext (HTTP) connections by default. Always use HTTPS endpoints.
- **Construct URIs Safely:** Always use `Uri.https(authority, unencodedPath, [queryParameters])` to build URLs safely.
- **Handle Status Codes:** Always validate `http.Response.statusCode`. Treat `200` and `201` as success. Throw explicit exceptions for other codes.
- **Prevent UI Jank:** Move expensive JSON parsing (>16ms) to a background isolate using `compute()`.
## Workflow: Executing HTTP Operations
- [ ] Add the `http` package to `pubspec.yaml`.
- [ ] Configure platform permissions (Internet permission in `AndroidManifest.xml`).
- [ ] Construct the target `Uri`.
- [ ] Execute the HTTP method (`http.get`, `http.post`, `http.put`, `http.delete`).
- [ ] Validate the response and parse JSON payload.
## Workflow: Implementing JSON Serialization
**Small prototype / simple models:** Use manual serialization with `dart:convert`.
- [ ] Define Model class with `final` properties.
- [ ] Implement `factory Model.fromJson(Map<String, dynamic> json)`.
- [ ] Implement `Map<String, dynamic> toJson()`.
**Production app / complex models:** Use code generation with `json_serializable` or `f