Implementing repository data retrieval
With our data sources – both local and remote – in place, it’s time to implement repository data retrieval. The repository pattern plays a pivotal role here, serving as the intermediary layer between our app’s business logic and data sources.
Enhancing our product repository
Let’s begin by modifying our AppProductRepository
. The repository will abstract the underlying data sources, allowing us to fetch candy data without worrying about whether it’s coming from a local database or an API service:
lib/app_product_repository.dart
class AppProductRepository implements ProductRepository { AppProductRepository({ required NetworkProductRepository remoteDataSource, required LocalProductRepository localDataSource, }) : _remoteDataSource = remoteDataSource, _localDataSource...