getImageSizeFromAsset static method
从 Asset 资源路径获取图片宽高
使用 ServicesBinding.rootBundle 加载资源。
Implementation
static Future<ImageResult<ImageSize>> getImageSizeFromAsset(
String assetPath,
) async {
try {
final data = await rootBundle.load(assetPath);
final bytes = data.buffer.asUint8List();
return getImageSizeFromBytes(bytes);
} catch (e) {
return ImageResult.failure(e.toString());
}
}