file static method

Widget file(
  1. File file, {
  2. Color? color,
  3. double? width,
  4. double? height,
  5. BoxFit fit = BoxFit.contain,
  6. AlignmentGeometry alignment = Alignment.center,
  7. PlaceholderBuilder? placeholderBuilder,
})

加载本地图片文件

Implementation

static Widget file(
  File file, {
  Color? color,
  double? width,
  double? height,
  BoxFit fit = BoxFit.contain,
  AlignmentGeometry alignment = Alignment.center,
  PlaceholderBuilder? placeholderBuilder,
}) {
  ImageType type = ImageType.fromPath(file.path);
  if (type.isSvg) {
    return SvgPicture.file(
      file,
      colorFilter: color == null
          ? null
          : ColorFilter.mode(color, BlendMode.srcIn),
      width: width,
      height: height,
      fit: fit,
      alignment: alignment,
      placeholderBuilder: (context) =>
          placeholderBuilder?.call(context) ??
          _defaultPlaceholder(width, height),
    );
  } else {
    return Image.file(
      file,
      color: color,
      width: width,
      height: height,
      fit: fit,
      alignment: alignment,
      errorBuilder: (context, _, _) =>
          placeholderBuilder?.call(context) ??
          _defaultPlaceholder(width, height),
    );
  }
}