Future<ChapterData?>
getChapters(- String mangaId,
- {List<String>? ids,
- String? title,
- List<String>? groups,
- String? uploader,
- String? volume,
- String? chapter,
- List<LanguageCodes>? translatedLanguage,
- List<LanguageCodes>? originalLanguage,
- List<LanguageCodes>? excludedOriginalLanguage,
- List<ContentRating>? contentRating,
- String? createdAtSince,
- String? updatedAtSince,
- String? publishedAtSince,
- String? includes,
- int? limit,
- int? offset}
)
Implementation
Future<ChapterData?> getChapters(String mangaId,
{List<String>? ids,
String? title,
List<String>? groups,
String? uploader,
String? volume,
String? chapter,
List<LanguageCodes>? translatedLanguage,
List<LanguageCodes>? originalLanguage,
List<LanguageCodes>? excludedOriginalLanguage,
List<ContentRating>? contentRating,
String? createdAtSince,
String? updatedAtSince,
String? publishedAtSince,
String? includes,
int? limit,
int? offset}) async {
var _chapterOffset = offset ?? 0;
var _ChapterLimit = limit ?? 10;
var response = await getChaptersResponse(
mangaId,
offset: _chapterOffset,
limit: _ChapterLimit,
ids: ids,
title: title,
groups: groups,
uploader: uploader,
volume: volume,
chapter: chapter,
translatedLanguage: translatedLanguage,
originalLanguage: originalLanguage,
excludedOriginalLanguage: excludedOriginalLanguage,
contentRating: contentRating,
createdAtSince: createdAtSince,
updatedAtSince: updatedAtSince,
publishedAtSince: publishedAtSince,
);
var headers = response.headers;
if (headers['x-ratelimit-remaining'] == '0') {
print('Rate Limit Exceeded.');
} else {
var data = ChapterData.fromJson(jsonDecode(response.body));
if (data.data.isNotEmpty) {
return data;
} else {
print(
'chapter with the manga ID $mangaId not found. Make sure the manga id isn\'t an empty String.');
}
}
}