file static method
Widget
file(
- File file, {
- Color? color,
- double? width,
- double? height,
- BoxFit fit = BoxFit.contain,
- AlignmentGeometry alignment = Alignment.center,
- 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),
);
}
}