Flutter 图像缩放但如何更改缩放位置

Flutter image zoomed but how to change zoom position

你好,我已经在 flutter 应用程序上实现了双击缩放功能,但是当图像被缩放时,当它处于缩放位置时我无法导航到图像的其他部分。 捏缩放工作正常, 双击缩放并重置为正常也可以正常工作。 唯一的问题是当图像处于缩放状态时无法在图像中移动。 请帮助我,这是我的代码:

GestureDetector(
            onDoubleTapDown: (details) {
              tapDownDetails = details;
            },
            onDoubleTap: () {
              final position = tapDownDetails?.localPosition;
              final double scale = 4;

              final x = -position!.dx * (scale - 1);
              final y = -position.dy * (scale - 1);

              final zoomed = Matrix4.identity()
                ..translate(x, y)
                ..scale(scale);

              final end = _controller!.value.isIdentity()
                  ? zoomed
                  : Matrix4.identity();

              _animation = Matrix4Tween(
                begin: _controller?.value,
                end: end,
              ).animate(
                CurveTween(curve: Curves.easeInOut)
                    .animate(_animationController!),
                // CurvedAnimation(parent: _animationController!, curve: Curves.easeInOut),
              );
              _animationController?.forward(from: 0);
            },
            child: InteractiveViewer(
              transformationController: _controller,
              clipBehavior: Clip.none,
              panEnabled: false,
              minScale: minScale,
              maxScale: maxScale,
              onInteractionStart: (details) {
                if (details.pointerCount < 2) return;
                if (entry == null) {
                  showOverlay(context);
                }
              },
              onInteractionUpdate: (details) {
                if (entry == null) return;
                this.scale = details.scale;
                entry!.markNeedsBuild();
              },
              onInteractionEnd: (details) {
                if (details.pointerCount != 1) return;
                resetAnimation();
              },
              child: Image(
                image: imageProvider,
              ),
            ),
          ),

删除此行或设置为 true,这是默认值。这将启用平移。

panEnabled: true,