如何解决如何根据容器调整传入图片的大小?
我用图片网络从网上拍了一张照片。因为我不知道传入图片的大小,所以容器不能是正确的大小。如何从网络获取图像大小或设置容器的大小?
class ZoomWidget extends StatelessWidget {
final String imagePath;
ZoomWidget(this.imagePath);
@override
Widget build(BuildContext context) {
return Container(//The code gives an error if I don't give the container a height.
height: MediaQuery.of(context).size.height * (0.6),child: PinchZoom(
image: Image.network(
imagePath,fit: BoxFit.scaleDown,loadingBuilder: (BuildContext context,Widget child,ImageChunkEvent? loadingProgress) {
if (loadingProgress == null) return child;
return Center(
child: CircularProgressIndicator(),);
},),zoomedBackgroundColor: Colors.transparent,onZoomStart: () {
print('Zoom started');
},onZoomEnd: () {
print('Zoom finished');
},);
}
}
屏幕截图
https://pub.dev/packages/pinch_zoom
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。