flutter-handling-http-and-json

Installation
Summary

HTTP requests and JSON serialization for Flutter REST API integration and data parsing.

  • Covers three HTTP methods (GET, POST, PUT, DELETE) with proper status code validation, HTTPS enforcement, and safe URI construction using Uri.https().
  • Offers two serialization strategies: manual fromJson/toJson for simple models, and code generation with json_serializable for complex nested structures.
  • Includes background parsing with compute() to prevent UI jank when processing large JSON payloads (1000+ items).
  • Provides platform-specific configuration guidance for Android and iOS network security policies.
SKILL.md

Handling HTTP and JSON

Contents

Core Guidelines

  • Enforce HTTPS: iOS and Android disable cleartext (HTTP) connections by default. Always use HTTPS endpoints. If HTTP is strictly required for debugging, configure network_security_config.xml (Android) and NSAppTransportSecurity (iOS).
  • Construct URIs Safely: Always use Uri.https(authority, unencodedPath, [queryParameters]) to safely build URLs. This handles encoding and formatting reliably, preventing string concatenation errors.
  • Handle Status Codes: Always validate the http.Response.statusCode. Treat 200 (OK) and 201 (Created) as success. Throw explicit exceptions for other codes (do not return null).
  • Prevent UI Jank: Move expensive JSON parsing operations (taking >16ms) to a background isolate using the compute() function.
  • Structured AI Output: When integrating LLMs, enforce reliable JSON output by specifying a strict JSON schema in the system prompt and setting the response MIME type to application/json.

Workflow: Executing HTTP Operations

Use this workflow to implement network requests using the http package.

Related skills
Installs
8.6K
Repository
flutter/skills
GitHub Stars
1.9K
First Seen
Mar 13, 2026