import 'package:cookie_jar/cookie_jar.dart'; class CookieJarImpl implements CookieJar { static const String _COOKIE_KEY_AUTH = 'ky_auth'; static const String _COOKIE_KEY_SDK = 'sdk'; static const String _COOKIE_AUTH_SAVE_KEY = 'KeyAuthCookie'; void saveCookieValue(String value) { //save cookie into sp } String getCookieValue() { //get cookie from sp return ""; } @override bool get ignoreExpires => false; @override Future delete(Uri uri, [bool withDomainSharedCookie = false]) { // TODO: implement delete throw UnimplementedError(); } @override Future deleteAll() { // TODO: implement deleteAll throw UnimplementedError(); } @override Future> loadForRequest(Uri uri) { List cookies = []; var cookie1 = Cookie(_COOKIE_KEY_SDK, '28')..domain = uri.host; cookies.add(cookie1); var cookie2 = Cookie(_COOKIE_KEY_AUTH, getCookieValue())..domain = uri.host; cookies.add(cookie2); return Future.value(cookies); } @override Future saveFromResponse(Uri uri, List cookies) { Cookie cookieValue = cookies.singleWhere((element) => element.name == _COOKIE_KEY_AUTH); if (cookieValue != null) { saveCookieValue(cookieValue.value); } } }