0

I have setup image assets like this:

/assets/images/img1.png
/assets/images/2.0x/img1.png
/assets/images/3.0x/img1.png
/assets/images/2.0x/img2.png
/assets/images/3.0x/img2.png

Then Image.asset('assets/images/img1.png') is displayed, but Image.asset('assets/images/img2.png') is not.

in pubspec.yaml assets defined like this:

  assets:
    - assets/images/

My question is do I have to add the /assets/images/img2.png ? If yes, then why? because the device is not 1x resolution. Probably 2x or 3x.

5
  • Can you show us your pubspec.yaml please? Commented Jun 26, 2019 at 19:40
  • just updated the question. Commented Jun 26, 2019 at 19:42
  • Thanks. When you say img2 is not displayed, you mean /assets/images/2.0x/img2.png? Because you don't have an img2.png on your assets folder root.. Commented Jun 26, 2019 at 20:05
  • You don't have a '/assets/images/img2.png'... you have a '/assets/images/2.0x/img2.png' and '/assets/images/3.0x/img2.png' Commented Jun 26, 2019 at 20:11
  • Hardly any devices use 1x... why do I need to define 1x image? Commented Jun 26, 2019 at 20:15

2 Answers 2

1

You are missing asset for /assets/images/img2.png Just resize img2.png by 50% and put img2.png in /assets/images/

Sign up to request clarification or add additional context in comments.

Comments

0

Could you please tell us what are you trying to achieve maybe you just need to add one image and using in a boxDecoration in a Container but if you add to you question what exactly want to do, our answer its gonna help you more.

1 Comment

Updated the question. Thanks

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.