/*获取网络图片高度
* */
Future<Size> getImageDimensions(String imageUrl) async {
final ImageProvider provider = NetworkImage(imageUrl);
final Completer<Size> completer = Completer<Size>();
final ImageStreamListener listener = ImageStreamListener(
(ImageInfo info, bool synchronousCall) {
final Size imageSize = Size(info.image.width.toDouble(), info.image.height.toDouble());
completer.complete(imageSize);
},
onError: (exception, stackTrace) {
completer.completeError(exception, stackTrace);
},
);
final ImageStream stream = provider.resolve(const ImageConfiguration());
stream.addListener(listener);
return completer.future;
}
01-09
1583
1583

被折叠的 条评论
为什么被折叠?



