diff --git a/lib/common/widgets/image_viewer/gallery_viewer.dart b/lib/common/widgets/image_viewer/gallery_viewer.dart index 787288ff8..f1c35e2eb 100644 --- a/lib/common/widgets/image_viewer/gallery_viewer.dart +++ b/lib/common/widgets/image_viewer/gallery_viewer.dart @@ -377,7 +377,7 @@ class _GalleryViewerState extends State } if (frame == null) { if (widget.quality == _quality) { - return const SizedBox.expand(); + return child; } else { return Image( image: CachedNetworkImageProvider( diff --git a/lib/common/widgets/image_viewer/image.dart b/lib/common/widgets/image_viewer/image.dart index 75b5aa9b1..2c82e5a9e 100644 --- a/lib/common/widgets/image_viewer/image.dart +++ b/lib/common/widgets/image_viewer/image.dart @@ -595,13 +595,14 @@ class _ImageState extends State with WidgetsBindingObserver { // } } - Widget result; + final Size childSize; + final bool isLongPic; + double? minScale, maxScale; if (_imageInfo != null) { - double? minScale, maxScale; final imgWidth = _imageInfo!.image.width.toDouble(); final imgHeight = _imageInfo!.image.height.toDouble(); final imgRatio = imgHeight / imgWidth; - final isLongPic = + isLongPic = imgRatio > StyleString.imgMaxRatio && imgHeight > widget.containerSize.height; if (isLongPic) { @@ -609,25 +610,25 @@ class _ImageState extends State with WidgetsBindingObserver { minScale = compatWidth / widget.containerSize.height * imgRatio; maxScale = math.max(widget.maxScale, minScale * 3); } - result = Viewer( - minScale: minScale ?? widget.minScale, - maxScale: maxScale ?? widget.maxScale, - isLongPic: isLongPic, - containerSize: widget.containerSize, - childSize: Size(imgWidth, imgHeight), - onDragStart: widget.onDragStart, - onDragUpdate: widget.onDragUpdate, - onDragEnd: widget.onDragEnd, - tapGestureRecognizer: widget.tapGestureRecognizer, - horizontalDragGestureRecognizer: widget.horizontalDragGestureRecognizer, - onChangePage: widget.onChangePage, - child: RawImage( - image: _imageInfo!.image, - ), - ); + childSize = Size(imgWidth, imgHeight); } else { - result = const SizedBox.expand(); + childSize = .zero; + isLongPic = false; } + Widget result = Viewer( + minScale: minScale ?? widget.minScale, + maxScale: maxScale ?? widget.maxScale, + isLongPic: isLongPic, + containerSize: widget.containerSize, + childSize: childSize, + onDragStart: widget.onDragStart, + onDragUpdate: widget.onDragUpdate, + onDragEnd: widget.onDragEnd, + tapGestureRecognizer: widget.tapGestureRecognizer, + horizontalDragGestureRecognizer: widget.horizontalDragGestureRecognizer, + onChangePage: widget.onChangePage, + child: RawImage(image: _imageInfo?.image), + ); if (!widget.excludeFromSemantics) { result = Semantics(