Skip to content
pubscout

dio_web_adapter

2.2.2, released 3 months ago by flutter.cn

Web and WASM HTTP client adapter for Dio.

WASM-ready
$ flutter pub add dio_web_adapter
Source repository

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.

  • talker_dio_logger

    A lightweight, customizable logger for Dio HTTP client built on Talker.

  • alice_dio

    Dio interceptor and network logger for Alice network inspector UI

  • dio_refresh

    Dio interceptor for automatic token refresh and retry on API failures

Works with

Packages commonly used together with dio_web_adapter: ones it builds on, ones built on it, and its own family.