plus_plugins
plus_plugins copied to clipboard
[Bug]: No save image item shown from v4 onwards on android
Platform
Android
Plugin
share_plus
Version
4.0.4 - 4.0.7
Flutter SDK
2.10.5
Steps to reproduce
- Upgrade share_plus to version 4.0.4 or later
- Share an image with Share.shareFiles([file_path], mimeTypes: ['image/png'])
- No Save image item shown.
Code Sample
import 'dart:io';
import 'dart:typed_data';
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:path_provider/path_provider.dart';
import 'package:share_plus/share_plus.dart';
import 'package:flutter/rendering.dart';
class SomeWidget extends StatelessWidget {
SomeWidget({Key? key}) : super(key: key);
final GlobalKey widgetToImageKey = GlobalKey();
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: SingleChildScrollView(
child: RepaintBoundary(
key: widgetToImageKey,
child: Column(children: [
const SizedBox(height: 100),
const Text("Some Text"),
ElevatedButton(onPressed: takePictureAndShare, child: const Text("Take Photo and share")),
]),
),
),
),
);
}
Future<void> takePictureAndShare() async {
RenderRepaintBoundary boundary = widgetToImageKey.currentContext!.findRenderObject() as RenderRepaintBoundary;
ui.Image image = await boundary.toImage();
final directory = (await getTemporaryDirectory()).path;
ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png);
Uint8List pngBytes = byteData!.buffer.asUint8List();
File imgFile = File('$directory/invoice.png');
await imgFile.writeAsBytes(pngBytes);
await Share.shareFiles(
[imgFile.path],
mimeTypes: ['image/*'],
);
}
}
Logs
none
Flutter Doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.10.5, on Microsoft Windows [Version 10.0.19043.1706], locale es-ES)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Chrome - develop for the web
[✓] Visual Studio - develop for Windows (Visual Studio Build Tools 2019 16.11.15)
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.67.2)
[✓] Connected device (3 available)
[✓] HTTP Host Availability
To confirm, this worked back in 4.0.3, correct?
To confirm, this worked back in 4.0.3, correct?
Sorry, i did not put it right, i does not work either on 4.0.3
In 4.0.0 - 4.0.2 i haven't tested, because my app require the minimun sdk on 16, but in 4.0.3, the plugin minimun sdk version requirement is 23 according to the documentation, and it was set back to 16 on version 4.0.3
But in version 3 of the plugin, the Save Image appeared in the share options, right?
But in version 3 of the plugin, the Save Image appeared in the share options, right?
That's correct
When I try my example app, this is what I get (Pixel 4 API 33), would you expect something else? I don't personally own an android, so I can not assess whether this is the "normal" behavior, but it looks right to me.
Up to that point the plugin works well.
What is supposed to happen is that the image must be sent to where you send it, excuse the redundancy, That is, if it was sent to a telegram chat, it should show me a preview of the image in telegram which does not happen, and for therefore the image is not sent. I have tried it with several destinations (telegram, whatsApp, Drive, etc...). In none, the preview is shown and the image is not sent either.
Thanks for narrowing this down, sadly I can not reproduce your issues:
I tested this with telegram (like you recommended) and everything works like a charm (with and without the explicit mimeTypes
argument).
OK, I am going to use your example and if it works, i am going to make it work somehow. Thanks
Hi there, has your issue been resolved? If yes please close this thread :)
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days