How to solve the problem of “another exception was thrown: Unable to load asset:” in flutter?
Here is the step for flutter how to load local images:
First, for use asset image in local, image location should be add in pubsec.yaml
flutter
assets:
- images/hero.png
- images/flower.png
# - images/a_dot_ham.jpeg
Next, add the widgets in your layouts:
Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Image.asset(
'images/hero.png',
fit: BoxFit.contain,
),
Image.asset(
'images/flower.png',
fit: BoxFit.cover,
),
]
)
Finally, execute the flutter commend to clean, and run again:
flutter clean
flutter run