DioImageProvider class

An ImageProvider that uses Dio to fetch images from a network URL, with support for a fallback asset image if the network image fails to load.

This class is useful when you need custom HTTP configurations or error handling provided by Dio, such as interceptors, custom headers, or logging.

Example Usage:

Image(
  image: DioImage(
    imageUrl: Uri.parse("https://example.com/image.png"),
    fallbackAssetPath: "assets/images/fallback.png",
  ),
)
Inheritance

Constructors

DioImageProvider({required Uri imageUrl, required String fallbackAssetPath})
Creates a new DioImageProvider with the given imageUrl and fallbackAssetPath.

Properties

dio → Dio
The Dio instance used for network requests.
final
fallbackAssetPath String
The asset path of the fallback image to use if the network image fails to load.
final
hashCode int
Returns a hash code based on the imageUrl and fallbackAssetPath.
no setteroverride
imageUrl Uri
The network URL of the image to load.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

createStream(ImageConfiguration configuration) ImageStream
Called by resolve to create the ImageStream it returns.
inherited
evict({ImageCache? cache, ImageConfiguration configuration = ImageConfiguration.empty}) Future<bool>
Evicts an entry from the image cache.
inherited
loadBuffer(DioImageProvider key, DecoderBufferCallback decode) ImageStreamCompleter
Converts a key into an ImageStreamCompleter, and begins fetching the image.
inherited
loadImage(DioImageProvider key, ImageDecoderCallback decode) ImageStreamCompleter
Loads the image asynchronously using the given key and decode callback.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
obtainCacheStatus({required ImageConfiguration configuration, ImageErrorListener? handleError}) Future<ImageCacheStatus?>
Returns the cache location for the key that this ImageProvider creates.
inherited
obtainKey(ImageConfiguration configuration) Future<DioImageProvider>
Obtains the key for this image provider, which is used for caching purposes.
override
resolve(ImageConfiguration configuration) ImageStream
Resolves this image provider using the given configuration, returning an ImageStream.
inherited
resolveStreamForKey(ImageConfiguration configuration, ImageStream stream, DioImageProvider key, ImageErrorListener handleError) → void
Called by resolve with the key returned by obtainKey.
inherited
toString() String
Returns a string representation of this image provider.
override

Operators

operator ==(Object other) bool
Compares this image provider to another for equality.
override