sweet_cookie_jar 1.1.0 copy "sweet_cookie_jar: ^1.1.0" to clipboard
sweet_cookie_jar: ^1.1.0 copied to clipboard

A most easily usable cookie management library in Dart. With SweetCookieJar, you can easily manage cookie on your application.

sweet_cookie_jar

A most easily usable cookie management library in Dart!

pub package codecov Analyzer Test

1. About #

SweetCookieJar is an open-sourced Dart library.
With SweetCookieJar, you can easily manage cookie on your application.

SweetCookieJar is a library that extends the functionality of the official Cookie class. It also works with Responses in the http package, and even if multiple set-cookie are set in the response header, which is a weak point in the http package, SweetCookieJar can manage these cookie information very easily!

No more difficult implementation is needed to handle multiple set-cookie set in response header in Dart. Just pass the Response to the constructor of SweetCookieJar!

1.1. Introduction #

1.1.1. Install Library #

With Dart:

 dart pub add sweet_cookie_jar

With Flutter:

 flutter pub add sweet_cookie_jar

1.1.2. Import It #

import 'package:sweet_cookie_jar/sweet_cookie_jar.dart';

1.1.3. Use SweetCookieJar #

import 'package:sweet_cookie_jar/sweet_cookie_jar.dart';

void main() {
    // The cookie set in the response header
    // will be extracted by the constructor process.
    final cookieJar = SweetCookieJar.from(response: response);

    if (cookieJar.isEmpty) {
        // It means that there is no cookie information
        // in the response header.
        return;
    }

    // You can find cookie by name easily.
    final cookie = cookieJar.find(name: 'AWSALB');
    print(cookie.name);
    print(cookie.value);

    // Also you can get cookie as JSON format.
    print(cookie.toJson());

    if (cookie.isExpired) {
        // Do something when cookie is expired.
        return;
    }
}

1.2. License #

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

1.3. More Information #

SweetCookieJar was designed and implemented by Kato Shinya.

11
likes
130
pub points
77%
popularity

Publisher

verified publishershinyakato.dev

A most easily usable cookie management library in Dart. With SweetCookieJar, you can easily manage cookie on your application.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

collection, http, universal_io

More

Packages that depend on sweet_cookie_jar