appendFileExtensionToImageUrl function

String appendFileExtensionToImageUrl(
  1. String url
)

This is a bug of Gallery Saver Package. It can not save image that's filename does not end with it's file extension like below. If imageUrl does not end with it's file extension, file extension is added to image url for saving.

Implementation

// "https://firebasestorage.googleapis.com/v0/b/eventat-4ba96.appspot.com/o/2019-Metrology-Events.jpg?alt=media&token=bfc47032-5173-4b3f-86bb-9659f46b362a"
/// If imageUrl does not end with it's file extension,
/// file extension is added to image url for saving.
String appendFileExtensionToImageUrl(String url) {
  final endsWithImageFileExtension =
      imageFileExtensions.firstWhere((s) => url.toLowerCase().endsWith(s), orElse: () => '');
  if (endsWithImageFileExtension.isNotEmpty) {
    return url;
  }

  final imageFileExtension = imageFileExtensions.firstWhere((s) => url.toLowerCase().contains(s), orElse: () => '');

  return url + imageFileExtension;
}