useExistingPhotoFor static method

Future<CropParameters?> useExistingPhotoFor({
  1. required BuildContext context,
  2. required ProductImage rawImage,
  3. required String barcode,
  4. required ImageField imageField,
  5. required bool isLoggedInMandatory,
  6. required ProductType? productType,
  7. required OpenFoodFactsLanguage language,
})

Implementation

static Future<CropParameters?> useExistingPhotoFor({
  required BuildContext context,
  required ProductImage rawImage,
  required String barcode,
  required ImageField imageField,
  required bool isLoggedInMandatory,
  required ProductType? productType,
  required OpenFoodFactsLanguage language,
}) async {
  final LocalDatabase localDatabase = context.read<LocalDatabase>();
  final File? imageFile = await downloadImageUrl(
    context,
    rawImage.getUrl(
      barcode,
      imageSize: ImageSize.ORIGINAL,
      uriHelper: ProductQuery.getUriProductHelper(productType: productType),
    ),
    DaoInt(localDatabase),
  );
  if (imageFile == null || !context.mounted) {
    return null;
  }

  return Navigator.of(context).push<CropParameters>(
    MaterialPageRoute<CropParameters>(
      builder: (BuildContext context) => CropPage(
        inputFile: imageFile,
        initiallyDifferent: true,
        isLoggedInMandatory: isLoggedInMandatory,
        cropHelper: ProductCropAgainHelper(
          barcode: barcode,
          productType: productType,
          imageField: imageField,
          imageId: int.parse(rawImage.imgid!),
          language: language,
        ),
      ),
      fullscreenDialog: true,
    ),
  );
}