This widget unifies the different methods on loading an image.

Features

  • support to load image from network
  • support to load image from file
  • support to load image from asset
  • support soft error handling, displaying a gray box if the path provided is not valid

This widget automatically detects which type of path/url/asset was passed to it.

Getting started

No prerequisites are required to use this package. Simply append it to your project.

Usage

Examples for each type of usage:

  • Load by path:
ImageWidget(
  imagePath: '/path/to/local/file.jpg', // Absolute path to the image on the local file system
  width: 100,
  height: 100,
  fit: BoxFit.fill,
)
  • Load by asset:
ImageWidget(
  imagePath: 'assets/images/my_local_image.png', // Path relative to the assets directory
  width: 100,
  height: 100,
  fit: BoxFit.cover,
)
  • Load by url:
ImageWidget(
  imagePath: 'https://example.com/image.jpg', // Full URL to the image on the web
  width: 100,
  height: 100,
  fit: BoxFit.scaleDown,
)

Additional information

Feel free to suggest and add modifications to this repository. This repository will be updated on demand.

Libraries

example
general_image_widget
A widget that loads and displays an image from a network URL, file path, or asset.