getImage method
Implementation
Widget getImage() {
if (imagePath.startsWith('http')) { //网络图片
return CachedNetworkImage(
imageUrl: imagePath,
width: width,
height: height,
fit: BoxFit.cover,
color: color,
placeholder: placeholder,
errorWidget: errorWidget,
);
} else if (imagePath.startsWith('images')) { // 项目内图片
return Image.asset('assets/$imagePath',
width: width,
height: height,
fit: BoxFit.cover,
color: color,
package: package,
);
} else { //加载手机里面的图片
return Image.file(File(imagePath),
width: width,
height: height,
fit: BoxFit.cover,
color: color,
);
}
}