Modalbottomsheet上的InteractiveViewer

发布于 2025-01-22 14:23:18 字数 2143 浏览 0 评论 0原文

我正在尝试使用InteractiveViewer使用showmodalbottomsheet。我希望用户能够缩放,然后使用捏和锅手势浏览照片。不幸的是,当我垂直做一个锅手势时,垂直draggesturerecognizer在手势领域的scale> scale> scale> scale> scale> scale> scale> scale>。

flutter: Gesture arena 48   ❙ ★ Opening new gesture arena.
flutter: Gesture arena 48   ❙ Adding: ScaleGestureRecognizer#962c4(debugOwner: GestureDetector)
flutter: Gesture arena 48   ❙ Adding: VerticalDragGestureRecognizer#57396(debugOwner: GestureDetector, start behavior: start)
flutter: Gesture arena 48   ❙ Closing with 2 members.
flutter: Gesture arena 48   ❙ Accepting: VerticalDragGestureRecognizer#57396(debugOwner: GestureDetector, start behavior: start)
flutter: Gesture arena 48   ❙ Self-declared winner: VerticalDragGestureRecognizer#57396(debugOwner: GestureDetector, start behavior: start)

这是我所知道的底部表代码

class PhotoViewerSheet extends StatelessWidget {
  static String route = '/photo-viewer';

  final ScoutingNoteAttachmentFile image;

  const PhotoViewerSheet({
    Key? key,
    required this.image,
  }) : super(key: key);

  static Future<void> show(BuildContext context) {
    return showModalBottomSheet(
      context: context,
      isScrollControlled: true,
      builder: (context) => Container(
        decoration: const BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.only(
            topLeft: Radius.circular(16.0),
            topRight: Radius.circular(16.0),
          ),
        ),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            const SizedBox(height: 10),
            const AppBottomSheetHeader(text: 'Photo'),
            const SizedBox(height: 10),
            SizedBox(
              height: context.screenHeight * 0.5,
              width: context.screenWidth,
              child: InteractiveViewer(
                child: const FlutterLogo(size: 200),
              ),
            ),
          ],
        ),
      ),
    );
  }
  
}

,在这种情况下,RawgentureDetector可能会有所帮助,但我不知道如何在这里使用它。

I'm trying to use InteractiveViewer inside modal bottom sheet using showModalBottomSheet. I want user to be able to zoom and then move through the photo using pinch and pan gestures. Unfortunately when I do a pan gesture vertically, VerticalDragGestureRecognizer is winning over ScaleGestureRecognizer on gesture arena.

flutter: Gesture arena 48   ❙ ★ Opening new gesture arena.
flutter: Gesture arena 48   ❙ Adding: ScaleGestureRecognizer#962c4(debugOwner: GestureDetector)
flutter: Gesture arena 48   ❙ Adding: VerticalDragGestureRecognizer#57396(debugOwner: GestureDetector, start behavior: start)
flutter: Gesture arena 48   ❙ Closing with 2 members.
flutter: Gesture arena 48   ❙ Accepting: VerticalDragGestureRecognizer#57396(debugOwner: GestureDetector, start behavior: start)
flutter: Gesture arena 48   ❙ Self-declared winner: VerticalDragGestureRecognizer#57396(debugOwner: GestureDetector, start behavior: start)

Here is my bottom sheet code

class PhotoViewerSheet extends StatelessWidget {
  static String route = '/photo-viewer';

  final ScoutingNoteAttachmentFile image;

  const PhotoViewerSheet({
    Key? key,
    required this.image,
  }) : super(key: key);

  static Future<void> show(BuildContext context) {
    return showModalBottomSheet(
      context: context,
      isScrollControlled: true,
      builder: (context) => Container(
        decoration: const BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.only(
            topLeft: Radius.circular(16.0),
            topRight: Radius.circular(16.0),
          ),
        ),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            const SizedBox(height: 10),
            const AppBottomSheetHeader(text: 'Photo'),
            const SizedBox(height: 10),
            SizedBox(
              height: context.screenHeight * 0.5,
              width: context.screenWidth,
              child: InteractiveViewer(
                child: const FlutterLogo(size: 200),
              ),
            ),
          ],
        ),
      ),
    );
  }
  
}

From what I know, RawGestureDetector could help in this situation but I don't know how to use it here.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一杆小烟枪 2025-01-29 14:23:18

您可以使用indrorepointerapporbpointer如果要禁用其他手势检测器
喜欢:

IgnorePointer(
  ignoring: true,
  child: SizedBox(
              height: context.screenHeight * 0.5,
              width: context.screenWidth,
              child: InteractiveViewer(
                child: const FlutterLogo(size: 200),
              ),
            )),

或者您也可以为transformationController添加transformation Controller
喜欢

InteractiveViewer(
                        transformationController: _transformationController,
                          onInteractionUpdate: (v) {
                            setState(() {
                              interactiveScale = _transformationController.value
                                  .getMaxScaleOnAxis();
                            });
                          },)

you can use IngrorePointer or AbsorbPointer if you want disable other gesture detectors
like:

IgnorePointer(
  ignoring: true,
  child: SizedBox(
              height: context.screenHeight * 0.5,
              width: context.screenWidth,
              child: InteractiveViewer(
                child: const FlutterLogo(size: 200),
              ),
            )),

or also you can add TransformationController for transformationController
like

InteractiveViewer(
                        transformationController: _transformationController,
                          onInteractionUpdate: (v) {
                            setState(() {
                              interactiveScale = _transformationController.value
                                  .getMaxScaleOnAxis();
                            });
                          },)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文