renderImage static method

Image renderImage(
  1. String nameOrAlias, {
  2. bool isProjectImage = false,
  3. OnImageWidgetConfig? imageConfig,
})

渲染asset图片 nameOrAlias 通过名称或别名查找全路径 isProjectImage 当为项目本身工程下图时以相对路径提供,避免部分图片转换Uint8List失败问题 imageConfig 图片配置对象

Implementation

static Image renderImage(String nameOrAlias, {bool isProjectImage = false, OnImageWidgetConfig? imageConfig}) {
  var imageFactory = ConfigManager.instance.getConfig(ImageKey.imageListKey);
  if (imageFactory is! ImageListFactory) {
    return Image.asset(imageConfig?.onDefaultImage() ?? "");
  }
  ImageListFactory imageListFactory = imageFactory;
  String alias = nameOrAlias.withoutExtension;
  ImageResponse? response = imageListFactory.getFlutterImageResponse(alias);
  if (response == null) {
    return Image.asset(imageConfig?.onDefaultImage() ?? "");
  }
  if (isProjectImage) {
    return Image.asset(response.relative ?? "");
  } else {
    return Image.asset(response.result ?? "");
  }
}