Skip to content

Support getting an asset file path from AssetBundle #11892

Closed

Description

@mit-mit

Currently you can load from an AssetBundle, and get the data inside the asset. However, in some cases you need to pass the path to the actual file holding the asset data; for example if you want to play back a video using the video_launcher plugin.

Activity

  1. added this to the 3: Current Milestone milestone on Sep 21, 2017
  2. added
    engineflutter/engine related. See also e: labels.
    frameworkflutter/packages/flutter repository. See also f: labels.
    c: new featureNothing broken; request for a new capability
    on Dec 18, 2017
  3. Hixie commented on Dec 19, 2017

    @Hixie
    Contributor

    @mit-mit @mravn-google I'm leaving this in the current milestone since it seems like video-related work, but please don't hesitate to move it out if it's not something you think we'll get to in the next few months.

  4. mit-mit commented on Dec 20, 2017

    @mit-mit
    MemberAuthor

    Yes, we should keep this. Should be fairly easy once the flx work completes.

  5. sroddy commented on Jan 15, 2018

    @sroddy
    Contributor

    Is there a workaround to get the root path of the asset directory other than getting it with a MethodChannel?

  6. szakarias commented on Jan 16, 2018

    @szakarias
    Contributor

    No, but we are in the process of redesigning our asset API and the plan is to make it possible to get the path of a given asset. Is there a particular use case that you would like support for?

  7. sroddy commented on Jan 16, 2018

    @sroddy
    Contributor

    No, my use case was to be able to get the absolute path of a video inside the assets in order to load it with the video player plugin

  8. xster commented on Jan 26, 2018

    @xster
    Member

    Posse had a similar issue where after selecting an asset from Flutter, there was no easy way to pass that asset reference to the native side without reading out the asset and shuffling all the bytes across platform channel.

  9. mit-mit commented on Jan 29, 2018

    @mit-mit
    MemberAuthor

    Yes, that's the same issue. We hope that @szakarias can get to this fairly soon

  10. arranf commented on Jan 29, 2018

    @arranf

    I also have a use case for detecting whether an asset is a part of the bundle and if not, fetching it from a remote source.

  11. 1 remaining item

  12. szakarias commented on Feb 23, 2018

    @szakarias
    Contributor

    I am currently working on how we handle assets on Android which will hopefully fix the slow startup, reduce the installed size and also make it possible to get a handle on an asset in the APK, which can be passed on, for instance to the video player.

  13. arranf commented on Feb 23, 2018

    @arranf
  14. MichaelSowah commented on Feb 27, 2018

    @MichaelSowah

    Hi @szakarias any updates? where are now on this? been a couple of months now...atleast we are just trying to find out progress and there's anything we can do to help as @arranf mentioned because for some os this is one of the major blocks for bring our apps live...thanks

  15. szakarias commented on Apr 6, 2018

    @szakarias
    Contributor

    Fixed, see the documentation.

  16. devxpy commented on Jul 15, 2018

    @devxpy

    I wish i had found this earlier.

  17. leifcr commented on Nov 3, 2018

    @leifcr

    Fixed, see the documentation.

    Any possibility of accessing the data through as a normal 'File' in dart?

    Example:

    File.new('assets/sqlitedatabase.db') ? 
    
  18. QB3L commented on Feb 18, 2019

    @QB3L

    I'm still not clear on how this was fixed. I'm trying to bundle some PDF files for displaying in my app and need the absolute path to them in order to open them. I don't see anything in AssetBundle documentation that gives me the path to them.

  19. mit-mit commented on Feb 19, 2019

    @mit-mit
    MemberAuthor

    The original scope of this bug was to offer an asset API for getting assets paths on the host platforms. Documentation was added for Android and iOS here:

    https://flutter.io/docs/development/ui/assets-and-images#android
    https://flutter.io/docs/development/ui/assets-and-images#ios

    It sounds like there is a request to have a similar API on the Dart side. That sounds reasonable, but I suggest you open a new issue for that request.

  20. QB3L commented on Feb 19, 2019

    @QB3L

    Thanks for the explanation @mit-mit now it's clearer. I misunderstood the scope of this completely. Will reopen another ticket

  21. RolfHendriks commented on Jun 13, 2019

    @RolfHendriks

    I have another use case and it is a rather simple one. Theming. I want an automatic way to get an asset path using a dark asset variation if available, otherwise using the normal path. So I need a fast, synchronous way to check for the existence of an asset without loading it. The minimum building block I need to implement this is to get the root path for assets. I can add functionality to my plugin to do this but this seems like a basic feature that should come packaged with Flutter automatically.

  22. lukepighetti commented on Sep 23, 2019

    @lukepighetti
    Contributor

    My use case is bundling a test video in my repo to use for a mock video picker service so i can do things like golden test thumbnail/film-strip widget that takes a file as argument. I don't see a way to achieve this without being able to get the path of an asset.

  23. augsun commented on Apr 7, 2020

    @augsun

    We hope that can get to this fairly soon, this question take me 1day to fine method.

  24. lock commented on Apr 25, 2020

    @lock

    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.

  25. locked and limited conversation to collaborators on Apr 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

a: videoVideo playbackc: new featureNothing broken; request for a new capabilitycustomer: posse (eap)engineflutter/engine related. See also e: labels.frameworkflutter/packages/flutter repository. See also f: labels.

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions