'Flutter crashing on failed PlatformAssetBundle
Running my app I get a crash, but stack trace doesn't go deep enough because of an Async call? I cannot figure out what is trying to grab an image?
Below is the assets part of my pubspec.yaml file
assets:
- assets/
- assets/images/
Using VSCode and it shows any images I reference or if I mouse over the reference it shows the images.
@protected
Future<ui.Codec> _loadAsync(AssetBundleImageKey key, DecoderCallback decode) async {
ByteData data;
// Hot reload/restart could change whether an asset bundle or key in a
// bundle are available, or if it is a network backed bundle.
try {
data = await key.bundle.load(key.name);
} on FlutterError {
PaintingBinding.instance.imageCache.evict(key);
rethrow; <---- crashes here
}
I am not grabbing any external images (URL) in my code. I added Google Maps SDK so maybe its something it is trying to grab? But not sure why no stack trace?
VSCode see the images before I send it to the iOS simulator. These are the images that it cannot find. It finds all other images referenced in the file.
Solution 1:[1]
Below is the assets part of my pubspec.yaml file
assets: - assets/ - assets/images/
Try to follow the indentation of the documentation.
Here is an example:
flutter:
assets:
- assets/my_icon.png
- assets/background.png
If the error still exist, try to follow the workaround here:
It worked for me:
- Set only full path to asset in pubspec.yaml
e.g.
assets: - assets/files/asset.txt - assets/images/icons/myicon.png
Whole folder not worked for me
- assets/
- Add
./
to the beginning of your asset path when you loading ite.g.
rootBundle.loadString('./assets/path/to your/asset.txt
flutter clean
Also, as mentioned in this comment, using flutter clean
is a good idea if there are some weird behavior from your app.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | MαπμQμαπkγVπ.0 |