Closed farshidinanloo closed 3 years ago
Hi @farshidinanloo,
Thanks for your feedback. I totally agree with you that using a single repository is not a good idea when you have been working on a big project with many data sources. However, I have used a single repository to showcase how we can interact with different layers and pass data between them.
In a project with many data sources, you might use a DataManager holding reference of all the repositories as shown below:
DataManager
abstract class DataManager
implements
JobRepository,
TaskRepository,
ReceiptRepository,
JobTaskReceiptRepository,
TaskTemplatesRepository,
UserRepository,
NotificationsRepository,
ConfigurationsRepository,
DataRepository,
ProblemRepository {}
JobRepository
abstract class JobRepository {
Future<Tuple2<List<Job>, List<Problem>>> getJobs({List<int> jobIds});
Future<bool> updateJob(Job job);
Future<bool> clearAllJobs();
Future<bool> removeJobs(List<int> jobIds);
Future<SyncResult> syncAllJobs();
}
I hope this answers your question but feel free to ask if you have any questions.
in this file lib/data/repository.dart there are multiple functions with separate business like (posts, login, theme and language) I guess it can be better to separate each of them to their own file so when project get bigger that repository file be clean and not bloated with many things.