import 'package:http/io_client.dart'; import "package:http/http.dart"; BaseClient getCookieClient() => IOClientWithCookies(); class IOClientWithCookies extends IOClient { String _accessToken; String _refreshToken; @override Future send(BaseRequest request) async { // String cookie = await getCookie(); // String getCookieString(String _) => cookie; // request.headers.update('cookie', getCookieString); return super.send(request).then((response) { if (response.headers.containsKey("x-imagini-accesstoken")) { this._accessToken = response.headers["x-imagini-accesstoken"]; } if (response.headers.containsKey("x-imagini-refreshtoken")) { this._refreshToken = response.headers["x-imagini-refreshtoken"]; } print("Access Token: $_accessToken"); print("Refresh Token: $_refreshToken"); return response; }); } }