getImageSize static method

Future<ImageResult<ImageSize>> getImageSize(
  1. String path
)

从文件路径或网络 URL 获取图片宽高

自动判断:如果字符串以 http://https:// 开头则下载后读取, 否则作为本地文件路径读取。

Implementation

static Future<ImageResult<ImageSize>> getImageSize(String path) async {
  try {
    final bytes = await _fetchBytes(path);
    return getImageSizeFromBytes(bytes);
  } catch (e) {
    return ImageResult.failure(e.toString());
  }
}