Hello Guys How are you all? Hope You all are fine. When I was trying to run my flutter app and suddenly I get the following error in my stack track. You might face Unable to load asset this error in a flutter. So today Here I come with all possible solutions for this error.
We are providing you all possible solutions to solve this error. let’s start this article without wasting your time.
How to solve Unable to load asset Flutter ?
- How to solve unable to load asset in flutter
to solve unable to load asset in flutter Generally this error cause of wrong indentation for assets in pubspec.yaml file, Not given proper path and extra whitespace in pubspec.yaml file. So here is all possible method to solve this error.
- unable to load asset in flutter
to solve unable to load asset in flutter Generally this error cause of wrong indentation for assets in pubspec.yaml file, Not given proper path and extra whitespace in pubspec.yaml file. So here is all possible method to solve this error.
Solution 1 : consider the indentation for assets.
Causes of this error is as below.
- Wrong indentation for
assets
in pubspec.yaml file. - Not given proper path.
- Extra whitespace in pubspec.yaml file
- consider the indentation for
assets
.
flutter:
assets:
- images/assets.png
- images/assets.png
- Indentation right method Example
flutter:
[2 whitespaces or 1 tab]assets:
[4 whitespaces or 2 tabs]- assets/image1.png
[4 whitespaces or 2 tabs]- assets/image2.png
Solution 2: flutter clean
flutter clean
,- Restart the android studio and emulator,
- giving full path in my image
image: AssetImage(
'assets/image1.png'
),
width: 300,
height: 300,
);
Solution 3: add each sub folder in a new line in pubspec.yaml
- You should start image path with assets word:
image: AssetImage('assets/image1.png')
- you must add each sub folder in a new line in pubspec.yaml
- then dont forgot to run flutter clean.
So it’s all About All possible solutions. Hope this above all solution helped you a lot. Comment below Your thoughts and your queries. And Also Comment on your suggestion here.
Solution 4: Use this indentation
flutter:
<space><space>assets:
<space><space><space><space>assets/
example:
flutter:
assets:
assets/
Also Read
- Flutter Error: MissingPluginException No implementation found for method
- How To Download File From URL And Save in Local Storage In Flutter
- Error: Could not find included file ‘Generated.xcconfig’ in search paths (in target ‘Runner’)
- Exception thrown while unbinding, java.lang.IllegalArgumentException: Service not registered in Flutter
- type ‘List‘ is not a subtype of type ‘List‘ Flutter
Leave a Reply