Dio is an HTTP client for Dart and Flutter with global settings, interceptors, uploads, downloads, timeouts, and custom adapters.
Overview
Dio helps Dart and Flutter applications talk to web APIs and download or upload data over HTTP. You create a client instance, set defaults such as base URL and timeouts, and issue GET, POST, QUERY, and other requests with optional query parameters and bodies.
The client supports request cancellation, progress callbacks for uploads and downloads, response typing as streams or raw bytes, and FormData for multipart uploads including multiple files. Interceptors let you log traffic, queue requests, or rewrite options and responses; transformers can change how bodies are encoded or decoded.
On the web, downloads use the browser’s save flow and CORS rules still apply. Optional plugins in the ecosystem add cookie management, HTTP/2, native adapters, and web-specific adapters. Third-party plugins can extend behavior further.
Dio runs wherever Dart and Flutter are supported, including mobile, desktop, and browser targets. Install it as a pub package dependency and import it into application code.
Key features
- Global BaseOptions and per-request Options
- Interceptors and QueuedInterceptor
- FormData and multipart file uploads
- Request cancellation and timeouts
- Custom HttpClientAdapter and transformers
- File download with progress callbacks
- HTTP/2 and web adapter plugins
- QUERY method with request body support
Use cases
- REST API calls in Flutter apps
- File uploads with progress reporting
- Shared HTTP defaults across a codebase
- Middleware-style request and response hooks
- Concurrent parallel HTTP requests