ExtendedImage.file constructor

ExtendedImage.file(
  1. File file, {
  2. Key? key,
  3. double scale = 1.0,
  4. String? semanticLabel,
  5. bool excludeFromSemantics = false,
  6. double? width,
  7. double? height,
  8. Color? color,
  9. Animation<double>? opacity,
  10. BlendMode? colorBlendMode,
  11. BoxFit? fit,
  12. AlignmentGeometry alignment = Alignment.center,
  13. ImageRepeat repeat = ImageRepeat.noRepeat,
  14. Rect? centerSlice,
  15. bool matchTextDirection = false,
  16. bool gaplessPlayback = false,
  17. FilterQuality filterQuality = FilterQuality.low,
  18. LoadStateChanged? loadStateChanged,
  19. BoxShape? shape,
  20. BoxBorder? border,
  21. BorderRadius? borderRadius,
  22. Clip clipBehavior = Clip.antiAlias,
  23. bool enableLoadState = false,
  24. BeforePaintImage? beforePaintImage,
  25. AfterPaintImage? afterPaintImage,
  26. ExtendedImageMode mode = ExtendedImageMode.none,
  27. bool enableMemoryCache = true,
  28. bool clearMemoryCacheIfFailed = true,
  29. DoubleTap? onDoubleTap,
  30. InitGestureConfigHandler? initGestureConfigHandler,
  31. bool enableSlideOutPage = false,
  32. BoxConstraints? constraints,
  33. Key? extendedImageEditorKey,
  34. InitEditorConfigHandler? initEditorConfigHandler,
  35. HeroBuilderForSlidingPage? heroBuilderForSlidingPage,
  36. bool clearMemoryCacheWhenDispose = false,
  37. Key? extendedImageGestureKey,
  38. int? cacheWidth,
  39. int? cacheHeight,
  40. bool isAntiAlias = false,
  41. double? compressionRatio,
  42. int? maxBytes,
  43. bool cacheRawData = false,
  44. String? imageCacheName,
  45. EdgeInsets layoutInsets = EdgeInsets.zero,
})

Creates a widget that displays an ImageStream obtained from a File.

The file, scale, and repeat arguments must not be null.

Either the width and height arguments should be specified, or the widget should be placed in a context that sets tight layout constraints. Otherwise, the image dimensions will change as the image is loaded, which will result in ugly layout changes.

On Android, this may require the android.permission.READ_EXTERNAL_STORAGE permission.

Use filterQuality to change the quality when scailing an image. Use the FilterQuality.low quality setting to scale the image, which corresponds to bilinear interpolation, rather than the default FilterQuality.none which corresponds to nearest-neighbor.

If excludeFromSemantics is true, then semanticLabel will be ignored.

Implementation

ExtendedImage.file(
  File file, {
  Key? key,
  double scale = 1.0,
  this.semanticLabel,
  this.excludeFromSemantics = false,
  this.width,
  this.height,
  this.color,
  this.opacity,
  this.colorBlendMode,
  this.fit,
  this.alignment = Alignment.center,
  this.repeat = ImageRepeat.noRepeat,
  this.centerSlice,
  this.matchTextDirection = false,
  this.gaplessPlayback = false,
  this.filterQuality = FilterQuality.low,
  this.loadStateChanged,
  this.shape,
  this.border,
  this.borderRadius,
  this.clipBehavior = Clip.antiAlias,
  this.enableLoadState = false,
  this.beforePaintImage,
  this.afterPaintImage,
  this.mode = ExtendedImageMode.none,
  this.enableMemoryCache = true,
  this.clearMemoryCacheIfFailed = true,
  this.onDoubleTap,
  this.initGestureConfigHandler,
  this.enableSlideOutPage = false,
  BoxConstraints? constraints,
  this.extendedImageEditorKey,
  this.initEditorConfigHandler,
  this.heroBuilderForSlidingPage,
  this.clearMemoryCacheWhenDispose = false,
  this.extendedImageGestureKey,
  int? cacheWidth,
  int? cacheHeight,
  this.isAntiAlias = false,
  double? compressionRatio,
  int? maxBytes,
  bool cacheRawData = false,
  String? imageCacheName,
  this.layoutInsets = EdgeInsets.zero,
})  :
      // FileImage is not supported on Flutter Web therefore neither this method.
      assert(
        !kIsWeb,
        'ExtendedImage.file is not supported on Flutter Web. '
        'Consider using either ExtendedImage.asset or ExtendedImage.network instead.',
      ),
      assert(cacheWidth == null || cacheWidth > 0),
      assert(cacheHeight == null || cacheHeight > 0),
      image = ExtendedResizeImage.resizeIfNeeded(
        provider: ExtendedFileImageProvider(
          file,
          scale: scale,
          cacheRawData: cacheRawData,
          imageCacheName: imageCacheName,
        ),
        compressionRatio: compressionRatio,
        maxBytes: maxBytes,
        cacheWidth: cacheWidth,
        cacheHeight: cacheHeight,
        cacheRawData: cacheRawData,
        imageCacheName: imageCacheName,
      ),
      constraints = (width != null || height != null)
          ? constraints?.tighten(width: width, height: height) ??
              BoxConstraints.tightFor(width: width, height: height)
          : constraints,
      handleLoadingProgress = false,
      super(key: key);