Skip to content
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

Resolution-aware image assets not generated #45

Closed
SerggioC opened this issue Oct 9, 2020 · 2 comments
Closed

Resolution-aware image assets not generated #45

SerggioC opened this issue Oct 9, 2020 · 2 comments

Comments

@SerggioC
Copy link

SerggioC commented Oct 9, 2020

Create the folders for:
- assets/images/1x/
- assets/images/2x/
- assets/images/3x/

Code for the assets in this folders are not generated.

Question: How does flutter gen handle images for different resolutions? This could be done automatically.

@lcdsmao
Copy link
Member

lcdsmao commented Oct 9, 2020

Hi @SerggioC! Thanks for using FlutterGen.

Question: How does flutter gen handle images for different resolutions? This could be done automatically.

Actually, this was done automatically.
If you arrange the file structure properly then those resolution-aware images will be handled properly by the flutter framework.
You can check this post: https://medium.com/@nileshsenta1991/flutter-resolution-aware-image-assets-234c82216cef.

For example:

  • Resolution-aware image
.../brand_logo.png
.../2.0x/brand_logo.png
.../3.0x/brand_logo.png
  • Pubspec
flutter:
  assets:
    - assets/brand_logo.png
  • Use FlutterGen
Image(
  image: Assets.brandLogo.image(),
)

@SerggioC
Copy link
Author

SerggioC commented Oct 9, 2020

Hi @lcdsmao
So I was defining this folders in pubspec.yaml, that is the error.

  assets:
    - assets/images/1x/
    - assets/images/2x/
    - assets/images/3x/

So we just need to put the images in the correct density folders (2.0x, 3.0x) and set pubspec:

  assets:
    - assets/images/

And the image is loaded with the correct density.

  image: Assets.brandLogo.image(),

Thanks for the help!

@SerggioC SerggioC closed this as completed Oct 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants