Skip to content
pubscout

dio_cookie_manager

3.5.0, released 4 months ago by flutter.cn

A cookie manager for Dio combining cookie_jar and Dio based on the interceptor algorithm.

Rock solid
$ flutter pub add dio_cookie_manager
Source repository

What it does

It automatically manages and persists cookies for network requests made using the Dio HTTP client. It acts as an interceptor to load stored cookies into requests and save new cookies from responses.

AI-written summary of version 3.5.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You are using Dio for networking and need automatic cookie management
  • You need to persist cookies across app restarts using file storage

Skip it when

  • You are not using the Dio HTTP client
  • Your API is entirely stateless and does not use cookies

Strengths

  • Seamless integration with Dio via interceptors
  • Supports persistent cookie storage using cookie_jar
  • Handles redirect requests and invalid cookies with specific options

Weaknesses

  • Tied strictly to Dio and cookie_jar packages
  • Upgrading major versions of cookie_jar can lead to losing previously stored cookies

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
2

Requires adding the package and attaching a CookieManager interceptor to your Dio instance.

import 'package:cookie_jar/cookie_jar.dart';
import 'package:dio/dio.dart';
import 'package:dio_cookie_manager/dio_cookie_manager.dart';

void main() async {
  final dio = Dio();
  final cookieJar = CookieJar();
  dio.interceptors.add(CookieManager(cookieJar));
  await dio.get("https://dart.dev");
}

Alternatives

Packages that do the same job and could replace dio_cookie_manager.

  • http

    If you are using Dart's core HTTP client instead of Dio and managing headers manually.

Works with

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