Repository navigation
Meta issue for the difficulty of using assets with Flutter #27802
Description
I wanted to try and highlight how several outstanding issues related to assets really hurt productivity:
-
Including all the files in a directory is only supported for the current package:
flutter: assets: - assets/country_flags/ # OK - packages/country_flag_icons/assets/ # Silently does not work
Related: Does not includes all the assets under a folder from external package #22944
-
Flutter packages (i.e. not apps) cannot declare their own assets:
# A package I'd like to host on Pub or GitHub. name: country_flag_icons flutter: assets: - assets/country_flags/
name: my_app dependencies: country_flag_icons: ^1.0.0
... will result in runtime asset errors. See above issue for why this is difficult to workaround.
Related: Flutter packages containing assets are hard to manage and not intuitive #22921
-
Asset inclusion only works by individual file or individual folder
# Let me write... flutter: assets: - assets/icons/**.png
Related: Support wildcard/globs in
flutter: assets:YAML #27801 -
Assets added to a directory are not picked up during hot reload/restart:
... leading the need of killing and restarting the app from scratch when working with assets.
Related: Trigger assets scan again if a file is added/removed to scanned folder #18896
-
Assets are not usable in (non-driver) tests:
... meaning that testing packages that provide assets is very difficult.
Activity
escamoteur commentedon Sep 4, 2019
Just one addition, packages can't define assets that are not inside the lib folder so that you have to do it like this:
bitsydarel commentedon Dec 2, 2019
Today I came across this at work, is there any update on this issue ?
lavahasif commentedon Sep 24, 2021
@escamoteur solved the problem
om-ha commentedon Jul 1, 2022
Any update on this please?
panda-p1 commentedon Oct 7, 2022
Is here any update?
skiryuk commentedon Jan 18, 2023
any update?
subzero911 commentedon Jan 30, 2023
Probably related:
#119562
I declare fonts in a package's pubspec, but the main app does not see these fonts, unless I explicitly add all of them to the pubspec too.
I suggest adding a directive for importing all fonts from the package:
[flutter_tools] Support package wildcard assets in app pubspec (flutt…
github-actions commentedon Sep 3, 2026
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 -vand a minimal reproduction of the issue.