Flutter: YouTube Search 03 - Pagination of Data in a Repository - BLoC Tutorial Course

preview_player
Показать описание
📗 Get the code from this part 👇👇

Welcome back to the 3rd part of the Flutter YouTube Search tutorial course. In the previous part we've created a data source which acts as an interface between the raw JSON data we get from the HTTP client and our Built Value classes. Data source, however, is a fairly low level class which would be cumbersome to put into a BLoC. We need to move up the ladder of abstraction.

For that we're going to create a repository. Repositories can combine data from multiple sources or, as in our case, make the data easier to get to. We can accomplish this simplification by preparing a nice way for data pagination.

Go to my website for more information, code examples and articles:

Follow me on social media:
Рекомендации по теме
Комментарии
Автор

Do we need query + nextPageToken or only nextPageToken?

peekpt
Автор

🎖🎖🎖🎖🎖🎖🎖🎖🎖🎖🎖🎖
Thanks veru much
You are great teacher

mrpakravian
Автор

Hey ResoCoder,
I am not sure if you really need the YoutubeRepository class and i am also not sure about calling it a 'Repository' neither. Why don't let the client (most likely a widget) handle the pagination? The widget itself can save the nextPageToken in it's state and then call the YoutubeDataSource with it. You just transfer the state logic into another class instead of letting the client handle all the state related logic. Also why do not throw the Exceptions, such as the NoSearchResultsException from the YoutubeDataSource class? I think the YoutubeRepository class is just a poor wrapper you dont really need.

frittenbuedchen