showPhotoBanner function

Future<File?> showPhotoBanner({
  1. required BuildContext context,
  2. required Product product,
  3. required ImageField imageField,
  4. required OpenFoodFactsLanguage language,
  5. TransientFile? transientFile,
})

Implementation

Future<File?> showPhotoBanner({
  required BuildContext context,
  required Product product,
  required ImageField imageField,
  required OpenFoodFactsLanguage language,
  TransientFile? transientFile,
}) async {
  final PhotoRowActions? action = await _showPhotoBanner(
    context: context,
    product: product,
    imageField: imageField,
    language: language,
    transientFile: transientFile,
  );

  if (!context.mounted || action == null) {
    return null;
  }

  return switch (action) {
    PhotoRowActions.takePicture => _takePicture(
      context: context,
      product: product,
      imageField: imageField,
      language: language,
      pictureSource: UserPictureSource.CAMERA,
    ),
    PhotoRowActions.selectFromGallery => _takePicture(
      context: context,
      product: product,
      imageField: imageField,
      language: language,
      pictureSource: UserPictureSource.GALLERY,
    ),
    PhotoRowActions.selectFromProductPhotos => _selectPictureFromProductGallery(
      context: context,
      product: product,
      imageField: imageField,
      language: language,
    ),
  };
}