Skip to content

InteractiveViewer blocks Gestures after zooming activity #136622

@osaxma

Description

@osaxma

Steps to reproduce

  1. Run the Sample Code provided below on MacOS
  2. Tap anywhere in the viewer (it should print Tap Tap).
  3. Using the trackpad on macOS:
    a. Pinch to zoom in (do it few even if fully zoomed in)
    b. Pinch to zoom out (again, do it few times even if fully zoomed out).
  4. Tap again, and nothing would print.

Step three and four are important to keep zooming-in few times and zooming-out few times. See screen recording where you can observe at the end that the taps don't work even after I reset the scale to 1.

Expected results

I expect gesture detectors to receive hits.

Actual results

Gesture detector is blocked even after resetting the scale to 1.

Code sample

Code sample
import 'package:flutter/material.dart';

/// Flutter code sample for [InteractiveViewer].

void main() => runApp(const InteractiveViewerExampleApp());

class InteractiveViewerExampleApp extends StatelessWidget {
  const InteractiveViewerExampleApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('InteractiveViewer Issue')),
        body: const InteractiveViewerExample(),
      ),
    );
  }
}

class InteractiveViewerExample extends StatefulWidget {
  const InteractiveViewerExample({super.key});

  @override
  State<InteractiveViewerExample> createState() => _InteractiveViewerExampleState();
}

class _InteractiveViewerExampleState extends State<InteractiveViewerExample> {
  final controller = TransformationController();

  void resetZoom() {
    setState(() {
      controller.value = Matrix4.identity();
    });
  }

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        print('Tap Tap');
      },
      child: Center(
        child: Column(
          children: [
            Center(
              child: TextButton(
                  onPressed: () {
                    resetZoom();
                  },
                  child: Text('Reset Zoom')),
            ),
            Expanded(
              child: InteractiveViewer(
                boundaryMargin: const EdgeInsets.all(20.0),
                transformationController: controller,
                minScale: 0.1,
                maxScale: 1.6,
                child: Container(
                  height: 1000,
                  width: 1000,
                  decoration: const BoxDecoration(
                    gradient: LinearGradient(
                      begin: Alignment.topCenter,
                      end: Alignment.bottomCenter,
                      colors: <Color>[Colors.red, Colors.orange, Colors.blue],
                      stops: <double>[0.0, 0.5, 1.0],
                    ),
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration

Screen.Recording.2023-10-16.at.10.00.18.AM.mov

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.13.6, on macOS 12.6 21G115 darwin-x64, locale en)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] VS Code (version 1.83.1)
[✓] Connected device (2 available)
[✓] Network resources

! Doctor found issues in 1 category.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: desktopRunning on desktopf: gesturesflutter/packages/flutter/gestures repository.found in release: 3.13Found to occur in 3.13found in release: 3.16Found to occur in 3.16frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-frameworkOwned by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions