Reputation: 11164
I have am images
folder and inside it i have table.png
and then i have a main_menu
folder in which i have another table.png
file.
When I do
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("images/table.png"),
)
),
it takes the table.png
image from the images/main_menu/
folder instead ... why is that?
Don't tell me it searches for the first place it finds the table.png
file and just displays that. And in this case table.png
under main_menu
is the first one it finds and that's why it displays it. It's just a hunch but ... if it's true, then this is a bug, no ?
Cheers.
Upvotes: 3
Views: 409
Reputation: 3
Reference this part: Flutter Docs: Specifying assets
Note: Only files located directly in the directory are included unless there are files with the same name inside a subdirectory (see Asset Variants). To add files located in subdirectories, create an entry per directory.
Upvotes: 0
Reputation: 8229
There are a different way to define images but i prefer this if picture in sub folder .
This is my folder of assets->images
I attaching Screenshot of folder below
And in pubspec.yaml
i define like this
hope it will works :D
And in class use like this
title: Image(
image: AssetImage('assets/images/xyz.png'),
),
Upvotes: 0
Reputation: 707
Try with this :
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage("./images/table.png"),
//instead of AssetImage("images/table.png")
)
),
Upvotes: 2