client_cookie 2.2.1

client_cookie #

Emulates Cookie store for dart:io and Flutter as if its a Browser.

Cookies #

Lets create a cookie named Client with value jaguar_resty:

main() {
  var cookie = new ClientCookie('Client', 'jaguar_resty', 

Use header getter obtain cookie in String format that can be directly added to HTTP request:

main() {
  var cookie = new ClientCookie('Client', 'jaguar_resty', 

Encoding a bunch of cookies #

ClientCookie has a static method called toHeader that encodes multiple cookies into a header string:

main() {
  var cookie1 = new ClientCookie('Client', 'jaguar_resty', new;
  var cookie2 = new ClientCookie('Client', 'jaguar_resty', new;
  print(ClientCookie.toHeader([cookie1, cookie2]));

Changelog #

2.1.8 #

  • parseSetCookie to parse set-cookie header and get a map of set cookies
  • ClientCookie.fromSetCookie to parse ClientCookie from one set-cookie item
  • Bug fixes

2.1.4 #

  • Dart 2 stable

2.1.2 #

  • Added cookie and cookiesMap to CookieStore

2.1.1 #

  • Renamed addOneCookie to parseOneCookie
  • Renamed addResponse to addFromResponse
  • Added addFromHeader

1.0.0 #

  • Added toHeader static method to ClientCookie


// Copyright (c) 2017, teja. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.

import 'package:client_cookie/client_cookie.dart';

main() {
  // Initializing a cookie
  final cookie1 = ClientCookie('Client', 'jaguar_resty',;

  // Cookie to header string

  // Encoding many cookies
  final cookie2 = ClientCookie('Who', 'teja',;
  print(ClientCookie.toSetCookie([cookie1, cookie2]));

  print(parseSetCookie(ClientCookie.toSetCookie([cookie1, cookie2])));

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  client_cookie: ^2.2.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:client_cookie/client_cookie.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 13, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5

Health suggestions

Fix lib/src/client_cookie_base.dart. (-2.96 points)

Analysis of lib/src/client_cookie_base.dart reported 6 hints, including:

line 40 col 20: Use = to separate a named parameter from its default value.

line 42 col 18: Use = to separate a named parameter from its default value.

line 84 col 11: Use isEmpty instead of length

line 85 col 9: DO use curly braces for all flow control structures.

line 257 col 33: DO use curly braces for all flow control structures.

Maintenance issues and suggestions

Homepage URL doesn't exist. (-20 points)

At the time of the analysis the homepage field was unreachable.

Package is getting outdated. (-3.84 points)

The package was last published 54 weeks ago.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.65 <3.0.0
http ^0.12.0 0.12.0+4
Transitive dependencies
async 2.4.0
charcode 1.1.3
collection 1.14.12
http_parser 3.1.3
meta 1.1.8
path 1.6.4
pedantic 1.9.0
source_span 1.6.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
test ^1.3.0