1

When I include 2x images only, it will show The asset assets/icons/xxx.png does not exist..

Must I include the 1x image version? Since iOS iPhones all provide retina screen(2x or 3x).

PS: I was making a app support iPhone only, and iOS 12+

JerryZhou
  • 4,566
  • 3
  • 37
  • 60

2 Answers2

0

from the flutter documentation

The main asset is assumed to correspond to a resolution of 1.0. For example, consider the following asset layout for an image named my_icon.png:

content_copy
  .../my_icon.png
  .../2.0x/my_icon.png
  .../3.0x/my_icon.png

On devices with a device pixel ratio of 1.8, the asset .../2.0x/my_icon.png would be chosen. For a device pixel ratio of 2.7, the asset .../3.0x/my_icon.png would be chosen.

Each entry in the asset section of the pubspec.yaml should correspond to a real file, with the exception of the main asset entry. If the main asset entry does not correspond to a real file, then the asset with the lowest resolution is used as the fallback for devices with device pixel ratios below that resolution. The entry should still be included in the pubspec.yaml manifest, however.

You may include the 1x Image to accommodate for older iPads and iPhones.

check this link for further info

cmd_prompter
  • 1,566
  • 10
  • 16
  • Actually, I was make app from target iOS 12.0, so 1x image is not need for iPhone only(Not include iPad) with iOS 12.0+ – JerryZhou Dec 21 '19 at 07:20
  • That's why I ask, why include useless image ? – JerryZhou Dec 21 '19 at 07:29
  • I have updated my answer. Share your `pubspec.yaml` file's code if you still get the error. – cmd_prompter Dec 21 '19 at 07:42
  • 1
    My question is it possible or way to **not** include the 1x images since I not used them. Not the usually situation when include assets. – JerryZhou Dec 21 '19 at 07:45
  • There is no mandatory requirement for you to include the 1x image but I think there's an error in your pubspec.yaml file and that's the reason for this error. – cmd_prompter Dec 21 '19 at 08:21
0

It is possible but you'll need to add them to pubspec.yaml directly.

So, if you have <path>/2.0x/image.webp and <path>/3.0x/image.webp, then you add

- <path>/image.webp

to pubspec.yaml and it'll work even if there's no image.webp in path.

Equilibrium
  • 694
  • 1
  • 7
  • 6