plus_plugins icon indicating copy to clipboard operation
plus_plugins copied to clipboard

[Bug]: No save image item shown from v4 onwards on android

Open Tecmesh opened this issue 2 years ago • 9 comments

Platform

Android

Plugin

share_plus

Version

4.0.4 - 4.0.7

Flutter SDK

2.10.5

Steps to reproduce

  1. Upgrade share_plus to version 4.0.4 or later
  2. Share an image with Share.shareFiles([file_path], mimeTypes: ['image/png'])
  3. 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

Tecmesh avatar Jun 08 '22 06:06 Tecmesh

To confirm, this worked back in 4.0.3, correct?

miquelbeltran avatar Jun 08 '22 06:06 miquelbeltran

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

Tecmesh avatar Jun 08 '22 06:06 Tecmesh

But in version 3 of the plugin, the Save Image appeared in the share options, right?

miquelbeltran avatar Jun 08 '22 12:06 miquelbeltran

But in version 3 of the plugin, the Save Image appeared in the share options, right?

That's correct

Tecmesh avatar Jun 08 '22 15:06 Tecmesh

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.

tempsnip

Coronon avatar Jun 12 '22 01:06 Coronon

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.

Tecmesh avatar Jun 12 '22 06:06 Tecmesh

Thanks for narrowing this down, sadly I can not reproduce your issues:

Capture1 Capture2

I tested this with telegram (like you recommended) and everything works like a charm (with and without the explicit mimeTypes argument).

Coronon avatar Jun 12 '22 17:06 Coronon

OK, I am going to use your example and if it works, i am going to make it work somehow. Thanks

Tecmesh avatar Jun 12 '22 18:06 Tecmesh

Hi there, has your issue been resolved? If yes please close this thread :)

Coronon avatar Jul 06 '22 08:07 Coronon

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

github-actions[bot] avatar Dec 28 '22 00:12 github-actions[bot]