mirrored_repositories/ZLHacpai/lib

import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:cached_network_image/cached_network_image.dart';

import 'log_utils.dart';

class ImageUtils {
  
  static ImageProvider getAssetImage(String name, {String format: 'png'}) {
    return AssetImage(getImgPath(name, format: format));
  }

  static String getImgPath(String name, {String format: 'png'}) {
    return 'assets/images/$name.$format';
  }


  static String getImgSVGPath(String name, {String format: 'svg'}) {
    return 'assets/images/$name.$format';
  }






  static ImageProvider getImageProvider(String imageUrl, {String holderImg: 'none'}) {
    if (TextUtil.isEmpty(imageUrl)) {
      return AssetImage(getImgPath(holderImg));
    }
    return CachedNetworkImageProvider(imageUrl, errorListener: () => Log.e("图片加载失败！"));
  }
}

