-
Notifications
You must be signed in to change notification settings - Fork 28.9k
Description
See #126612.
If unfamiliar with the concept of assets in Flutter, see Adding assets and images.
TL;DR: There are multiple users that use fake/mock/stub implements of AssetBundle
in tests. AssetBundle
is used for loading assets in flutter apps. Nearly all assets in a bundle are ones that user chooses to include, but the framework also bundles its own asset, the asset manifest. This means that users need to handle the call to load the asset manifest in their load
override, but it's unlikely that they will be aware of this (or even what the asset manifest is).
While there is perhaps a greater discussion to be had around whether or not flutter bundling files (namely the asset manifest) with an app should have the ability to break these tests, we can perhaps start with something smaller to help these users. Here are some suggestions, none of which are mutually exclusive:
- In the call to load the asset manifest, we can catch the vague
FormatException
and augment the message with a more useful note. - Improve the documentations of
DefaultAssetBundle
, which is (probably) commonly used to provide/inject test implementations ofAssetBundle
. We could make an explicit note about how to override this for custom tests, and/or we could could consider changing the example code to look more like one of the examples on this comment on #126612 (thanks @eerive).