dio_web_adapter
2.2.2, released 3 months ago by flutter.cn
Web and WASM HTTP client adapter for Dio.
What it does
Provides the underlying browser HTTP client adapter (BrowserHttpClientAdapter) for Dio on the web platform, including WASM support. It handles browser-based networking via XMLHttpRequest and triggers browser downloads with Blob URLs. Most users access it automatically through the main Dio package.
AI-written summary of version 2.2.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to explicitly configure browser-specific Dio settings such as withCredentials or CORS warnings.
- You need custom or pinned web adapter behavior when using Dio on Flutter Web or Dart Web.
Skip it when
- You only target non-web platforms (IO/native mobile and desktop).
- You are using standard Dio configuration without needing direct web adapter adjustments, as it is already embedded in Dio.
Strengths
- Supports both standard JS and WebAssembly (WASM) environments.
- Enables file downloads on web using Blob URLs and browser download anchors.
- Provides built-in CORS preflight warnings and enriched error messages.
Weaknesses
- Downloads must buffer the entire response into memory before triggering the browser download.
- File append modes and local deleteOnError are not supported on web.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 4
Already embedded inside package:dio; explicit dependency is optional.
import 'package:dio/dio.dart';
void main() async {
final dio = Dio();
dio.httpClientAdapter = BrowserHttpClientAdapter(withCredentials: true);
final response = await dio.get('https://dart.dev');
print(response);
}Alternatives
Packages that do the same job and could replace dio_web_adapter.
- http2
An HTTP/2 implementation in Dart for low-level transport and pooled HTTP/2 requests.
91Compare - talker_dio_logger
A lightweight, customizable logger for Dio HTTP client built on Talker.
92Compare - alice_dio
Dio interceptor and network logger for Alice network inspector UI
82Compare - dio_refresh
Dio interceptor for automatic token refresh and retry on API failures
74Compare
Works with
Packages commonly used together with dio_web_adapter: ones it builds on, ones built on it, and its own family.
- webdio_web_adapter depends on itLightweight bindings for browser APIs via JS interop
- http_parserdio_web_adapter depends on itA platform-independent package for parsing and serializing HTTP formats.
- dio_cookie_managerSame familyA cookie manager for Dio combining cookie_jar and Dio based on the interceptor algorithm.
- native_dio_adapterSame familyA Dio HTTP client adapter that uses native platform HTTP stacks via cupertino_http and cronet_http.
- dio_http2_adapterSame familyHTTP/2 adapter for Dio with connection reuse and header compression
- dioBuilt on dio_web_adapterA powerful HTTP networking package for Dart and Flutter with interceptors and request cancellation.