addTask static method
Implementation
static Future<void> addTask({
required BuildContext context,
required int pageSize,
required int totalSize,
required ProductType productType,
}) async {
final LocalDatabase localDatabase = context.read<LocalDatabase>();
final String uniqueId = await _operationType.getNewKey(
localDatabase,
totalSize: totalSize,
soFarSize: 0,
);
final BackgroundTask task = _getNewTask(
uniqueId,
WorkType.offline.getWorkTag(productType),
pageSize,
totalSize,
productType,
);
if (!context.mounted) {
return;
}
await task.addToManager(
localDatabase,
context: context,
queue: BackgroundTaskQueue.longHaul,
);
}