Skip to content

[path_provider] getDownloadsDirectory() doesn't work for iOS and Android. #93198

Description

@curvednebula

Currently getDownloadsDirectory() has the following documentation:

/// Path to the directory where downloaded files can be stored.
/// This is typically only relevant on desktop operating systems.
///
/// On Android and on iOS, this function throws an [UnsupportedError] as no equivalent
/// path exists.

It isn't quite clear why this API can't return paths to iOS' and Android's Downloads folders? I think both has equivalent folders. Am I missing something?

Activity

  1. changed the title [-][path_provider] getDownloadsDirectory() should work for iOS and Android too.[/-] [+][path_provider] getDownloadsDirectory() doesn't work for iOS and Android.[/+] on Nov 6, 2021
  2. darshankawar commented on Nov 8, 2021

    @darshankawar
    Member

    The method seems to be only supported on desktop platforms such as macOS. If you use that method, you'll see a message something like: Functionality only available on macOS.
    The documentation also says that, for mobile platform, there's no equivalent path exists and hence the limitation.

  3. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Nov 8, 2021
  4. guillermin commented on Nov 24, 2021

    @guillermin

    I'm not sure about iOS, but Android definitely does have a downloads folder, whose path is obtainable with:
    Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath();

    I think this should be added to the path_provider_android plugin (I can make a PR if it will be considered for inclusion)

  5. curvednebula commented on Nov 24, 2021

    @curvednebula
    Author

    I'm not sure about iOS, but Android definitely does have a downloads folder, whose path is obtainable with: Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath();

    I think this should be added to the path_provider_android plugin (I can make a PR if it will be considered for inclusion)

    I think this sounds good even if there is no iOS equivalent.

  6. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Nov 24, 2021
  7. darshankawar commented on Nov 29, 2021

    @darshankawar
    Member

    Keeping it open for further insights from the team. @guillermin Feel free to submit the PR.

  8. guillermin commented on Nov 30, 2021

    @guillermin

    I just submitted PR flutter-team-archive/plugins#4559 with this change.

  9. 12 remaining items

  10. talhakhan1297 commented on Aug 14, 2023

    @talhakhan1297

    If Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) is deprecated, Is there any other way to achieve this in Android?

  11. stuartmorgan-g commented on Aug 14, 2023

    @stuartmorgan-g
    Contributor

    If Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) is deprecated, Is there any other way to achieve this in Android?

    Please see my comment above.

  12. talhakhan1297 commented on Aug 17, 2023

    @talhakhan1297

    I have submitted a PR, please have a look: flutter/packages#4708

  13. added
    r: fixedIssue is closed as already fixed in a newer version
    on Aug 31, 2023
  14. github-actions commented on Sep 14, 2023

    @github-actions

    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.

  15. locked as resolved and limited conversation to collaborators on Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityp: path_providerPlugin that provides resolved paths to some platform directoriespackageflutter/packages repository. See also p: labels.platform-androidAndroid applications specificallyplatform-iosiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions