addCookies method

dynamic addCookies(
  1. HttpClientResponse response
)

Implementation

addCookies(HttpClientResponse response) {
  List<String>? cookies = response.headers["set-cookie"];
  if (cookies?.isEmpty == false) {
    cookies?.forEach((element) {
      List<String> data = element.split(";");
      String head = data[0];
      List<String> parts = head.split("=");
      if (parts.length > 1) {
        Cookie cookie = Cookie(parts[0].trim(), parts[1].trim());
        // CookieManager.
        CookieManager().addCookie(cookie);
      }
    });
  }
}