addTask static method

Future<void> addTask({
  1. required BuildContext context,
  2. required int pageSize,
  3. required int totalSize,
  4. required ProductType productType,
})

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,
  );
}