8000 [image picker] - Documentation needs fixes and more explanation · Issue #62304 · flutter/flutter · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[image picker] - Documentation needs fixes and more explanation #62304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
febg11 opened this issue Jul 26, 2020 · 5 comments · Fixed by flutter/plugins#3098
Closed

[image picker] - Documentation needs fixes and more explanation #62304

febg11 opened this issue Jul 26, 2020 · 5 comments · Fixed by flutter/plugins#3098
Labels
p: image_picker The Image Picker plugin. package flutter/packages repository. See also p: labels.

Comments

@febg11
Copy link
febg11 commented Jul 26, 2020

Hi,

I have recently updated my image picker version and I have encountered a few changes problems.

  1. Your readme says that
API 29+
No configuration required - the plugin should work out of the box.

API < 29
Add android:requestLegacyExternalStorage="true" as an attribute to the <application> tag in AndroidManifest.xml. The attribute is false by default on apps targeting Android Q.

Correct me if I'm wrong but aren't these the wrong way around?

  1. The version I was on also did not talk about MainActivity being destroyed by android in the readme... Is this a problem that was present on older versions or has this been caused by something in the newer versions of the imagepicker.

  2. I am having trouble implementing my version of retrieveLostData() mainly because I cant seem to be able to recreate the error. Is there a method I can use that will force the Main Activity to be destroyed so I can test my future builder logic?

  3. Furthermore I use the provider package to manage my application state which I alter when picking images. I can't tell if i need to update state again when the main activity is destroyed or if the current data will persist (as it hasn't ever happened). I imagine the answer to number 3 will help answer this.

Please can you help debug this as I currently have code written that has never ran and I can't recreate a scenario that will cause retrieveLostData() to be called.

@TahaTesser
Copy link
Member

Hi @febg11

  1. I agree, readme needs an update
  2. Needs readme update
  3. Can you please provide and a complete reproducible minimal code sample
  4. this is not related to image_picker but i will try based on 3.

Can you also please provide your flutter doctor -v your flutter run --verbose running your code sample and picking image
Thank you

@TahaTesser TahaTesser added in triage Presently being triaged by the triage team waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds labels Jul 27, 2020
@febg11
Copy link
Author
febg11 commented Jul 29, 2020

My code has quite a lot going on but the simplest example would be the example code provided but the flutter team... here.


  Future<void> retrieveLostData() async {
    final LostData response = await _picker.getLostData();
    if (response.isEmpty) {
      return;
    }
    if (response.file != null) {
      if (response.type == RetrieveType.video) {
        isVideo = true;
        await _playVideo(response.file);
      } else {
        isVideo = false;
        setState(() {
          _imageFile = response.file;
        });
      }
    } else {
      _retrieveDataError = response.exception.code;
    }
  }



  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: !kIsWeb && defaultTargetPlatform == TargetPlatform.android
            ? FutureBuilder<void>(
                future: retrieveLostData(),
                builder: (BuildContext context, AsyncSnapshot<void> snapshot) {
...
...
...

This isnt a bug per say I am just struggling to find.a method to get what is called retrieveLostData() in the example to be called by the future builder where the response.file is not null.

The read me states:
"Android system -- although very rarely -- sometimes kills the MainActivity after the image_picker finishes. When this happens, we lost the data selected from the image_picker. You can use retrieveLostData to retrieve the lost data in this situation. For example:"
...
"There's no way to detect when this happens, so calling this method at the right place is essential. We recommend to wire this into some kind of start up check. Please refer to the example app to see how we used it."

I am just looking for a method that will force the MainActivity to be killed so I can actually debug what comes back in response.file. Being able to debug it will help al lot as its kind of broken my current process flow (which is fine).

I don't really think my flutter run output will help as its would running the image picker example app just fine... I need a method to effectively force an error.

Thanks for replying so quickly :)

Side note
it also says this is very rare... How often does this actually occur as I dont think I have had it happen to me yet.

@no-response no-response bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Jul 29, 2020
@TahaTesser TahaTesser removed the in triage Presently being triaged by the triage team label Jul 30, 2020
@TahaTesser TahaTesser changed the title Flutter image picker - Help with getLostData() [image picker] - Documentation Jul 30, 2020
@TahaTesser TahaTesser changed the title [image picker] - Documentation [image picker] - Documentation needs fixes and more explanation Jul 30, 2020
@TahaTesser TahaTesser added documentation p: image_picker The Image Picker plugin. labels Jul 30, 2020
@febg11
Copy link
Author
febg11 commented Sep 24, 2020

Any update on this? its been quite a while

@amanv8060
Copy link
Contributor
amanv8060 commented Sep 26, 2020

For 3 @febg11

Add some debugprint in retrieveLostData Function after

if (response.file != null) {

you can enable dont keep activites in dev options and then push your app to background ,after selecting any image , as soon as you push it to background , the debug connection would be terminated , now run your app again , it should log the debugprint in the console

hope it helps

@github-actions
Copy link
github-actions bot commented Aug 7, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 7, 2021
@flutter-triage-bot flutter-triage-bot bot added the package flutter/packages repository. See also p: labels. label Jul 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p: image_picker The Image Picker plugin. package flutter/packages repository. See also p: labels.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
0