KasemJaffer / receive_sharing_intent

A Flutter plugin that enables flutter apps to receive sharing photos, text and url from other apps.
Apache License 2.0
321 stars 369 forks source link

Unexpected behaviour of reset method on Android #274

Open martinogarrizzo5 opened 5 months ago

martinogarrizzo5 commented 5 months ago

It seems that the reset method of the library doesn't really resets the state of ReceiveSharingIntent.getInitialMedia(). So each time I navigate to my loading screen I re-execute this action obtaining an old recycled value instead of getting a null value

KasemJaffer commented 5 months ago

I just tested this and its working for me.

martinogarrizzo5 commented 5 months ago

I called the reset method in my loading screen in this way:

    final sharedFiles = await ReceiveSharingIntent.getInitialMedia();
    if (sharedFiles.isNotEmpty) {
      ReceiveSharingIntent.reset(); // prevent recycling of the same files
      debugPrint("Received ${sharedFiles.length} files");
      await FileShareUtils.handleSharedFiles(sharedFiles, router);
    }

It usually works fine but there is a case where it doesn't seem to be as expected. With the app closed I went to the image gallery and choosed one or more images and shared them to the app. This opened successfully the app with the desired images. Then I swiped from the left (I have a Pixel phone) to exit from the app putting it in background state. When I recovered the app from the opened tabs the app reloaded the loading screen that contains the provided lines of code and it resulted that the old images were recycled unexpectedly. Can you check this case? Thanks