next<T> method

Future<T> next<T>(
  1. String url, {
  2. required CancelToken cancelToken,
})

下一页

Implementation

Future<T> next<T>(
  String url, {
  required CancelToken cancelToken,
}) async {
  final response = await _httpClient.get<String>(
    url.replaceFirst("app-api.pixiv.net", targetIPGetter.call()),
    cancelToken: cancelToken,
  );

  final responseData = response.data!;

  if (T == Comments) {
    return Comments.fromJson(jsonDecode(responseData)) as T;
  }
  if (T == Illusts) {
    return Illusts.fromJson(jsonDecode(responseData)) as T;
  }
  if (T == Novels) {
    return Novels.fromJson(jsonDecode(responseData)) as T;
  }
  if (T == Users) {
    return Users.fromJson(jsonDecode(responseData)) as T;
  }
  if (T == SearchIllust) {
    return SearchIllust.fromJson(jsonDecode(responseData)) as T;
  }
  if (T == BookmarkTags) {
    return BookmarkTags.fromJson(jsonDecode(responseData)) as T;
  }
  throw Exception('类型错误');
}