buildImageProvider static method

ImageProvider<Object> buildImageProvider(
  1. dynamic value, {
  2. int? cacheWidth,
  3. int? cacheHeight,
  4. double? compressionRatio,
  5. int? maxBytes,
  6. bool cacheRawData = false,
  7. String? imageCacheName,
  8. double scale = 1.0,
  9. Map<String, String>? headers,
  10. bool cache = true,
  11. int retries = 3,
  12. Duration? timeLimit,
  13. Duration timeRetry = const Duration(milliseconds: 100),
  14. CancellationToken? cancelToken,
  15. String? cacheKey,
  16. bool printError = true,
  17. Duration? cacheMaxAge,
  18. AssetBundle? bundle,
  19. String? package,
})

Implementation

static ImageProvider buildImageProvider(
  dynamic value, {
  int? cacheWidth,
  int? cacheHeight,
  double? compressionRatio,
  int? maxBytes,
  bool cacheRawData = false,
  String? imageCacheName,
  double scale = 1.0,

  /// [ExtendedNetworkImageProvider]
  Map<String, String>? headers,
  bool cache = true,
  int retries = 3,
  Duration? timeLimit,
  Duration timeRetry = const Duration(milliseconds: 100),
  CancellationToken? cancelToken,
  String? cacheKey,
  bool printError = true,
  Duration? cacheMaxAge,

  /// [ExtendedAssetImageProvider]
  AssetBundle? bundle,
  String? package,
}) {
  if (value is File) {
    return BaseResizeImage.file(value,
        cacheWidth: cacheWidth,
        cacheHeight: cacheHeight,
        maxBytes: maxBytes,
        compressionRatio: compressionRatio,
        cacheRawData: cacheRawData,
        imageCacheName: imageCacheName,
        scale: scale);
  } else if (value is Uint8List) {
    return BaseResizeImage.memory(value,
        cacheWidth: cacheWidth,
        cacheHeight: cacheHeight,
        maxBytes: maxBytes,
        compressionRatio: compressionRatio,
        cacheRawData: cacheRawData,
        imageCacheName: imageCacheName,
        scale: scale);
  } else if (value is String) {
    return value.startsWith('http') || value.startsWith('blob:http')
        ? BaseResizeImage.network(value,
            cacheWidth: cacheWidth,
            cacheHeight: cacheHeight,
            maxBytes: maxBytes,
            compressionRatio: compressionRatio,
            cacheRawData: cacheRawData,
            imageCacheName: imageCacheName,
            scale: scale,
            headers: headers,
            cache: cache,
            cancelToken: cancelToken,
            retries: retries,
            timeRetry: timeRetry,
            timeLimit: timeLimit,
            cacheKey: cacheKey,
            printError: printError,
            cacheMaxAge: cacheMaxAge)
        : BaseResizeImage.asset(value,
            cacheWidth: cacheWidth,
            cacheHeight: cacheHeight,
            maxBytes: maxBytes,
            compressionRatio: compressionRatio,
            cacheRawData: cacheRawData,
            imageCacheName: imageCacheName,
            bundle: bundle,
            package: package);
  }
  return BaseResizeImage.asset('');
}