-
Notifications
You must be signed in to change notification settings - Fork 26.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent Asset Image path across Mobile and Web platforms #86833
Comments
Hi @kchatr, Thanks for filing the issue I am able to reproduce it an image asset located at Web (works both ways)
Mobile (Android/IOS)
The issue is reproducible on both stable and master. flutter doctor -v
|
@yjbanov Any reason that the web needs to allow both ways? |
The current behavior seems to date back to the very beginnings of web support in Flutter and we never seriously re-evaluated it. On a sample app with the following asset structure:
The following in flutter:
uses-material-design: true
assets:
- images/foo.png
- assets/images2/bar.png And the following code: ...
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image.asset('images/foo.png'),
Image.asset('assets/images/foo.png'),
Image.asset('images2/bar.png'),
Image.asset('assets/images2/bar.png'),
],
),
... I see the following behaviors between
Other than the case with the I think what may be going on here is the fact that we have two "root" directories both being sources of assets:
When the server receives a request, without looking into A solution might be to have @jonahwilliams may have some context on this. |
I encountered the same issue, and am solving this by simply adding a step to my GitHub Actions:
But this should not be necessary. Instead, the bundling should put the files into the right directory from the start. |
Steps to Reproduce
images
, a subfolder withinassets
assets/images
to the pubspec.yaml and runflutter pub get
AssetImage("images/selected_image")
Expected results:
The image retrieved from assets and displayed.
Actual results:
On Flutter Web, the above code functions as expected and the image is retrieved; in order to get the image to display on mobile, however, the code must be modified to
AssetImage("assets/images/selected_image")
. This does not impact the appearance of the image on Web, but it is inconsistent behaviour that can lead to some elusive bugs.Logs
The text was updated successfully, but these errors were encountered: