Photo_view: [BUG] Delay around 0.4s with GestureDetector in PhotoView.customChild

Created on 29 May 2020  路  2Comments  路  Source: fireslime/photo_view

Describe the bug
GestureDetector inside PhotoView.customChild detects taps with delay of around 0.4s which is quite noticeable. I try to use Listener instead of GestureDetector and it seems it works good, but gestures is useful also for my needs.

To Reproduce
Paste this code in the default flutter project in main.dart, tap on the screen and look at the output.
I tested it in web and windows builds.

import 'package:flutter/material.dart';
import 'package:photo_view/photo_view.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    DateTime timeGestureStart;
    DateTime timeListenerStart;
    Duration diff;

    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: PhotoView.customChild(
        child: GestureDetector(
          onTap: () {
            timeGestureStart = DateTime.now();
            print('GestureDetector');
            diff = timeGestureStart.difference(timeListenerStart);
            print('diff ' + diff.toString());
          },
          child: Listener(
            onPointerDown: (PointerDownEvent event) {
              timeListenerStart = DateTime.now();
              print('Listener');
            },
            child: Container(
              color: Colors.greenAccent,
              child: Text('Sample text'),
            ),
          ),
        ),
      ),
    );
  }
}

What is the current behavior?
Listener and GestureDetector works with delay between each other.
Here is calculated difference in this code as a Duration:
diff 0:00:00.388052

Expected behavior
Expected to see no delay in general and working of the GestureDetector and Listener at the same time.

Screenshots
bugtouch

Additional context
It seems it's similar to this issue #233
Maybe there is a sort of gesture disambiguation problem.

Logs
photo_view: ^0.9.2

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[鈭歖 Flutter (Channel master, 1.19.0-2.0.pre.193, on Microsoft Windows [Version 10.0.17763.1217], locale ru-RU)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
X Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions.
[鈭歖 Chrome - develop for the web
[鈭歖 Visual Studio - develop for Windows (Visual Studio Community袙聽2019 16.4.2)
[鈭歖 Android Studio (version 3.6)
[鈭歖 VS Code (version 1.43.2)
[鈭歖 Connected device (3 available)

bug

Most helpful comment

I think this is due to the fact that the package expects a double tap, but the double tap function cannot be disabled. I did not find how to do it

All 2 comments

I think this is due to the fact that the package expects a double tap, but the double tap function cannot be disabled. I did not find how to do it

We push the image to full screen on tap and the delay is noticeable. Hopefully this can be solved in the package itself somehow, instead of finding some hack to fix it :)

Was this page helpful?
0 / 5 - 0 ratings