upsplash-flutter
upsplash-flutter copied to clipboard
Bug in fetchEvent
Hi @xyarim I saw that in the file photo_list_bloc.dart there are two bugs!
- Instruction CurrentPage++ passes old value and then update itself
- Unsplash api error: page=0 gives the same result of page=1
I fixed like following:
if (currentState is InitialPhotoListState) {
final photos = await photoRepository.getPhotos(1);
yield PhotoListLoaded(photos, 1);
} else if (currentState is PhotoListLoaded) {
int currentPage = currentState.page + 1;
final photos = await photoRepository.getPhotos(currentPage);
print("current_page = $currentPage");
yield photos.isEmpty
? currentState.copyWith(photos)
: PhotoListLoaded(currentState.photos + photos, currentPage);
}
I hope you'll enjoy it!
Angelo