youtube_explode_dart
youtube_explode_dart copied to clipboard
[BUG] issue implementing pagination using the .nextPage() method
Describe the bug The .nextPage() method provided by the SearchList and also VidoSearchList tends to return videos that have already been fetched in the initial search api call resulting in duplicate videos in the lisitng. Is this the expected beahvaiour or am I doing something wrong?
To Reproduce Include the code which doesn't work in the code markdown..
Future<VideoModelList> fetchVideosFromExplode(String videoName,
{bool loadMore = false}) async {
try {
final ytExplode = YoutubeExplode();
final searchList = await ytExplode.search.search(videoName);
log('search results from explode $searchList');
log('---------------------------');
if (loadMore) {
final searches = await searchList.nextPage();
if (searches != null) {
var videosList = VideoModelList.fromJson(searches);
return videosList;
} else {
return VideoModelList(videoList: []);
}
} else {
var videosList = VideoModelList.fromJson(searchList);
return videosList;
}
} on YoutubeExplodeException catch (e) {
throw YoutubeExplodeException(e.message);
} catch (e) {
log('video search from explode error $e');
throw ServerException();
}
}
Stacktrace Include here the stacktrace (if applicable).
Enviroment: (please complete the following information):
- Enviroment: [Flutter o Dart VM]
- Version 3.10.5
- YoutubeExplode Version ^2.0.1