[For ios] Saving image that's filename does not end with it's file extension (#651)

pull/652/head
Develeste 3 years ago committed by GitHub
parent bd80406bf9
commit 076eaf75b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      lib/src/widgets/embeds/default_embed_builder.dart

@ -162,6 +162,26 @@ Widget _menuOptionsForReadonlyImage(
color: Colors.greenAccent,
text: 'Save'.i18n,
onPressed: () {
const List<String> imageFormats = [
'.jpeg',
'.png',
'.jpg',
'.gif',
'.webp',
'.tif',
'.heic'
];
List endsWithFormats = imageFormats.where((imageFormat) => imageUrl.toLowerCase().endsWith(imageFormat)).toList();
if (endsWithFormats.length == 0) {
for(int i = 0; i < imageFormats.length; i++) {
if (imageUrl.toLowerCase().contains(imageFormats[i])) {
imageUrl += imageFormats[i];
break;
}
}
}
GallerySaver.saveImage(imageUrl).then((_) {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text('Saved'.i18n)));

Loading…
Cancel
Save