flutter-core:flutter-data-networking
Master HTTP clients, REST APIs, GraphQL integration, WebSockets, and JSON serialization in Flutter applications. Use when implementing API calls, handling network requests, parsing JSON, or working with real-time data.
What this skill does
# Flutter Data Networking Master HTTP clients, REST APIs, GraphQL, WebSockets, and JSON serialization in Flutter applications. ## When to Use This Skill Use this skill when working with Flutter applications that need to: - Make HTTP requests to REST APIs or web services - Implement GraphQL queries, mutations, or subscriptions - Establish real-time bidirectional communication with WebSockets - Serialize and deserialize JSON data with type safety - Handle network errors, timeouts, and offline scenarios - Implement authentication and authorization headers - Build offline-first applications with data synchronization - Upload or download files over the network - Create robust API clients with interceptors and middleware ## Overview Networking is fundamental to modern Flutter applications. Whether you're fetching data from a REST API, subscribing to real-time updates via WebSockets, or querying a GraphQL backend, Flutter provides powerful tools and packages to handle all networking scenarios efficiently and reliably. This skill covers the complete spectrum of networking in Flutter, from basic HTTP requests to advanced patterns like offline-first architecture, request interceptors, and automatic retry strategies. You'll learn to choose the right networking solution for your needs and implement it following industry best practices. ## HTTP Client Packages Flutter offers multiple HTTP client options, each suited to different use cases: ### http Package The official `http` package is Flutter's simplest HTTP client, ideal for straightforward API calls. It provides basic GET, POST, PUT, DELETE methods with minimal configuration. Use it for simple applications or when you need a lightweight solution without advanced features. The package is cross-platform, supporting Android, iOS, macOS, Windows, Linux, and web. However, it requires platform-specific permissions configuration, such as internet permission in AndroidManifest.xml for Android and network client entitlements for macOS. ### Dio Package Dio is a powerful, feature-rich HTTP client that has become the industry standard for Flutter networking. It excels with: - **Global Configuration**: Set base URLs, headers, timeouts, and other options globally for all requests - **Interceptors**: Intercept requests, responses, and errors for logging, authentication, or transformation - **Request Cancellation**: Cancel in-flight requests when they're no longer needed - **FormData Support**: Upload files with multipart form data - **Download Progress**: Track download progress for large files - **Automatic Retries**: Configure retry logic for failed requests - **Custom Adapters**: Replace the default HTTP adapter with custom implementations Dio's interceptor system is particularly powerful, allowing you to implement cross-cutting concerns like JWT authentication, request logging, error handling, and response caching without duplicating code across your application. ### Choosing the Right Client For production applications, Dio is typically the better choice due to its robust feature set and excellent error handling. Use the basic `http` package only for simple apps or quick prototypes. For enterprise applications requiring advanced features like certificate pinning, custom adapters, or sophisticated retry logic, Dio provides the necessary flexibility. ## REST API Integration REST (Representational State Transfer) APIs are the most common backend architecture for Flutter applications. Implementing REST APIs effectively requires understanding HTTP methods, status codes, headers, and error handling. ### CRUD Operations REST APIs typically expose four core operations (CRUD): - **CREATE**: POST requests to create new resources - **READ**: GET requests to retrieve existing resources - **UPDATE**: PUT or PATCH requests to modify resources - **DELETE**: DELETE requests to remove resources Each operation should be wrapped in a service or repository class that handles serialization, error handling, and business logic. This separation of concerns makes your code more testable and maintainable. ### Authentication Patterns Most production APIs require authentication, typically implemented using: - **Bearer Tokens**: JWT tokens sent in the Authorization header - **API Keys**: Static keys passed in headers or query parameters - **OAuth 2.0**: Token-based authentication with refresh tokens Dio interceptors are ideal for implementing authentication, automatically adding authentication headers to every request and handling token refresh when tokens expire. ### Error Handling Robust error handling distinguishes production-quality apps from prototypes. Your networking layer should handle: - **Network Errors**: Connection timeouts, DNS failures, no internet - **HTTP Errors**: 4xx client errors, 5xx server errors - **Serialization Errors**: Invalid JSON or schema mismatches - **Business Logic Errors**: Application-specific error codes Implement a consistent error handling strategy using custom exception types and a centralized error handler that can display appropriate messages to users. ## GraphQL Integration GraphQL is an alternative to REST that allows clients to request exactly the data they need, reducing over-fetching and under-fetching. The `graphql_flutter` package provides comprehensive GraphQL support for Flutter. ### Core Concepts GraphQL operates through three operation types: - **Queries**: Read operations that fetch data - **Mutations**: Write operations that create, update, or delete data - **Subscriptions**: Real-time operations that push updates to clients Unlike REST, GraphQL uses a single endpoint and a typed schema that defines available operations and data structures. This schema provides excellent type safety and enables powerful tooling. ### graphql_flutter Widgets The package provides three primary widgets: - **Query**: Executes GraphQL queries and rebuilds when data changes - **Mutation**: Provides a callback to execute mutations - **Subscription**: Opens a WebSocket connection for real-time updates All widgets must be wrapped in a GraphQLProvider that configures the GraphQL client, including the endpoint URL, authentication, and caching policies. ### Caching and Optimistic Updates graphql_flutter includes a sophisticated caching system that normalizes data by type and ID. This enables: - **Cache-first queries**: Return cached data immediately, then update if needed - **Optimistic updates**: Update the UI immediately, before server confirmation - **Cache persistence**: Save cache to disk for offline access Proper cache configuration significantly improves perceived performance and enables offline functionality. ## WebSocket Communication WebSockets provide full-duplex communication channels over a single TCP connection, enabling real-time bidirectional data flow. They're essential for features like chat, live notifications, collaborative editing, and real-time dashboards. ### web_socket_channel Package Flutter's `web_socket_channel` package provides a Stream-based API for WebSocket communication. The package abstracts platform differences and provides a consistent interface across all Flutter platforms. WebSocket connections follow a lifecycle: 1. **Connection**: Establish a WebSocket connection to a URL (ws:// or wss://) 2. **Communication**: Send messages via the sink, receive via the stream 3. **Closure**: Close the connection gracefully when done ### Stream-Based Architecture WebSockets integrate naturally with Flutter's reactive architecture through Streams. Use StreamBuilder widgets to display real-time data, and StreamControllers to manage WebSocket state in your business logic layer. ### Error Handling and Reconnection Production WebSocket implementations must handle: - **Connection Failures**: Network issues, server unavailability - **Disconnections**: Unexpected connection drops - **Reconnection Logic**: Exponential backoff for automatic reconnection
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.