getImageProvider function
Implementation
ImageProvider? getImageProvider(Uri resolvedUri,
{int? contextId, cache = 'auto', BoxFit objectFit = BoxFit.fill, int? cachedWidth, int? cachedHeight}) {
ImageType imageType = parseImageUrl(resolvedUri, cache: cache);
ImageProviderFactory factory = _getImageProviderFactory(imageType);
switch (imageType) {
case ImageType.cached:
return factory(
resolvedUri,
CachedNetworkImageProviderParams(contextId,
cachedWidth: cachedWidth, cachedHeight: cachedHeight, objectFit: objectFit));
case ImageType.network:
return factory(
resolvedUri,
CachedNetworkImageProviderParams(contextId,
cachedWidth: cachedWidth, cachedHeight: cachedHeight, objectFit: objectFit));
case ImageType.file:
File file = File.fromUri(resolvedUri);
return factory(
resolvedUri,
FileImageProviderParams(file,
cachedWidth: cachedWidth, cachedHeight: cachedHeight, objectFit: objectFit));
case ImageType.dataUrl:
// Data URL: https://tools.ietf.org/html/rfc2397
// dataurl := "data:" [ mediatype ] [ ";base64" ] "," data
UriData data = UriData.fromUri(resolvedUri);
if (data.isBase64) {
return factory(
resolvedUri,
DataUrlImageProviderParams(data.contentAsBytes(),
cachedWidth: cachedWidth, cachedHeight: cachedHeight, objectFit: objectFit));
}
return null;
case ImageType.blob:
// TODO: support blob data type
return null;
case ImageType.assets:
return factory(
resolvedUri,
ImageProviderParams(
cachedWidth: cachedWidth, cachedHeight: cachedHeight, objectFit: objectFit));
}
}