getQuestions method
- LocalDatabase localDatabase,
- int count
override
Implementation
@override
Future<List<RobotoffQuestion>> getQuestions(
LocalDatabase localDatabase,
int count,
) async {
final RobotoffQuestionResult result = await RobotoffAPIClient.getQuestions(
ProductQuery.getLanguage(),
deviceId: OpenFoodAPIConfiguration.uuid,
user: ProductQuery.getReadUser(),
countries: <OpenFoodFactsCountry>[ProductQuery.getCountry()],
count: count,
questionOrder: RobotoffQuestionOrder.popularity,
serverType: ServerType.openFoodFacts,
uriHelper: ProductQuery.uriRobotoffHelper,
);
if (result.questions?.isNotEmpty != true) {
return <RobotoffQuestion>[];
}
final List<String> barcodes = <String>[];
for (final RobotoffQuestion question in result.questions!) {
if (question.barcode != null) {
barcodes.add(question.barcode!);
}
}
if (barcodes.isNotEmpty) {
await ProductRefresher().silentFetchAndRefreshList(
barcodes: barcodes,
localDatabase: localDatabase,
productType: ProductType.food,
);
}
return result.questions!;
}