addTask static method
- String barcode, {
- required ProductType? productType,
- required ImageField imageField,
- required BuildContext context,
- required OpenFoodFactsLanguage language,
Adds the background task about unselecting a product image.
Implementation
static Future<void> addTask(
String barcode, {
required ProductType? productType,
required ImageField imageField,
required BuildContext context,
required OpenFoodFactsLanguage language,
}) async {
if (BackgroundTaskBarcode.isBarcodeToBeIgnored(barcode, context)) {
return;
}
final LocalDatabase localDatabase = context.read<LocalDatabase>();
final String uniqueId = await _operationType.getNewKey(
localDatabase,
barcode: barcode,
);
final BackgroundTaskBarcode task = _getNewTask(
barcode,
productType ?? ProductType.food,
imageField,
uniqueId,
language,
);
if (!context.mounted) {
return;
}
await task.addToManager(
localDatabase,
context: context,
queue: BackgroundTaskQueue.fast,
);
}