flutter-http-and-json
Secure HTTP networking and JSON handling for Flutter apps with background parsing support.
- Implements CRUD operations (GET, POST, PUT, DELETE) using the
httppackage with safe URL construction viaUri.https()and strict status code validation - Provides strongly typed JSON serialization and deserialization using Dart 3 pattern matching with factory constructors and
toJson()methods - Offloads large JSON parsing to background isolates via
compute()to prevent UI jank on payloads exceeding 16ms parse time - Integrates structured JSON schemas for AI model outputs, including Gemini response validation with
firebase_vertexai - Requires
httppackage inpubspec.yaml, Dart 3 null safety, and platform-specific internet permissions (Android manifest, macOS entitlements)
flutter-http-json-networking
Goal
Manages HTTP networking and JSON data handling in Flutter applications. Implements secure, asynchronous REST API calls (GET, POST, PUT, DELETE) using the http package. Handles JSON serialization, background parsing via isolates for large datasets, and structured JSON schemas for AI model integrations. Assumes the http package is added to pubspec.yaml and the environment supports Dart 3 pattern matching and null safety.
Decision Logic
When implementing JSON parsing and serialization, evaluate the following decision tree:
- Payload Size:
- If the JSON payload is small, parse synchronously on the main thread.
- If the JSON payload is large (takes >16ms to parse), use background parsing via
compute()to avoid UI jank.
- Model Complexity:
- If the data model is simple or a quick prototype, use manual serialization (
dart:convert). - If the data model is highly nested or part of a large production app, STOP AND ASK THE USER: "Should we configure
json_serializableandbuild_runnerfor automated code generation?"
- If the data model is simple or a quick prototype, use manual serialization (
Instructions
1. Configure Platform Permissions
Before making network requests, ensure the target platforms have the required internet permissions.
Android (android/app/src/main/AndroidManifest.xml):
More from flutter/skills
flutter-building-layouts
Builds Flutter layouts using the constraint system and layout widgets. Use when creating or refining the UI structure of a Flutter application.
10.6Kflutter-architecting-apps
Architects a Flutter application using the recommended layered approach (UI, Logic, Data). Use when structuring a new project or refactoring for scalability.
10.4Kflutter-animating-apps
Implements animated effects, transitions, and motion in a Flutter app. Use when adding visual feedback, shared element transitions, or physics-based animations.
9.6Kflutter-managing-state
Manages application and ephemeral state in a Flutter app. Use when sharing data between widgets or handling complex UI state transitions.
9.6Kflutter-theming-apps
Customizes the visual appearance of a Flutter app using the theming system. Use when defining global styles, colors, or typography for an application.
9.5Kflutter-implementing-navigation-and-routing
Handles routing, navigation, and deep linking in a Flutter application. Use when moving between screens or setting up URL-based navigation.
9.3K