I created a new project using this command on the terminal:
flutter create test_app
Then, I created the assets folder and an images folder. I have added one image to this folder for testing.
test_app/assets/images/
test_app/assets/images/note.png
I have edited pubspec.yaml for the assets folder. (I made sure that there was no indentation related problem and I did as it says in the documentation.)
flutter:
# The following line ensures that the Material Icons font is
# included with your application so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- assets/images/
Then, I added this line to a column that has some widgets in the main.dart file.
Image(image: AssetImage('images/note.png')),
I have done everything right but why it does not work I could not get it? I have done some projects in past, there was no problem. I have tried to create many projects to solve this problem but I couldn't do it.
Unable to load asset: images/note.png
...
...
Image provider: AssetImage(bundle: null, name: "images/note.png")
Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#e7b4d(), name: "images/note.png", scale: 1.0)
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.22.5, on Mac OS X 10.15.6 19G2021 darwin-x64,
locale en-TR)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 12.0)
[✓] Android Studio (version 4.0)
[✓] VS Code (version 1.52.0)
[✓] Connected device (1 available)
• No issues found!
I have tried the iOS simulator and Android Phone.
My computer is macOS Catalina 10.15.6.
Thank you...