Loading images

To load an image, use the AssetImage
class in a widget’s build() method.

For example, your app can load the background
image from the asset declarations above:

Anything using the default asset bundle inherits resolution
awareness when loading images. (If you work with some of the lower
level classes, like ImageStream or ImageCache,
you’ll also notice parameters related to scale.)

Device pixel ratio depends on

MediaQueryData.size which requires to have either a

MaterialApp or

CupertinoApp as an ancestor of your

AssetImage.

Asset images in package dependencies

To load an image from a package dependency,
the package argument must be provided to AssetImage.

For instance, suppose your application depends on a package
called my_icons, which has the following directory structure:

To load the image, use: