Я разобрался!
вы можете использовать их перехватчики, чтобы получить файлы cookie из ответа и добавить их в запросы:
Вот предложение о том, как ваш класс api может управлять файлами cookie.
import 'package: jaguar_retrofit / jaguar_retrofit.dart';
import 'package:jaguar_serializer/src/repo/repo.dart';
import 'package:jaguar_resty/jaguar_resty.dart' as resty;
import 'package:jaguar_resty/jaguar_resty.dart';
import 'package:http/http.dart';
import 'package:client_cookie/client_cookie.dart';
@GenApiClient(path: "apiPath")
class MyApi extends _$MyApiClient implements ApiClient{
@override
resty.Route base;
@override
SerializerRepo serializers;
MyApi({this.base, this.serializers}){ //Prepare the API in its constructor
globalClient = IOClient();
List<ClientCookie> cookies = List<ClientCookie>(); //Prepare alist of cookies
this.base.after((resty.StringResponse response){
Map map = response.headers.map((key, value){
return MapEntry(key, value);
});
String cookieStr = map["set-cookie"]; //Extract cookies from response header
print("Cookies Str: $cookieStr");
if (cookieStr != null){
cookies.clear();
cookies.addAll(Utils.cookies(cookieStr)); //Build your cookies and add them to the list
}
}
);
this.base.before((base1){ //This is 'before 'interceptor
base1.cookies(cookies); //add the cookies list to queries here
}
);
}//ApiConstructor
@GetReq(path: "something")
Future<dynamic> getSomething();
}