Git Product home page Git Product logo

Comments (2)

lcdsmao avatar lcdsmao commented on May 17, 2024 2

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(),
)

from flutter_gen.

SerggioC avatar SerggioC commented on May 17, 2024

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!

from flutter_gen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.