Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'onTap' does not work in gestureRecognizers property #133

Open
Vignesh-dev12 opened this issue Mar 19, 2021 · 5 comments
Open

'onTap' does not work in gestureRecognizers property #133

Vignesh-dev12 opened this issue Mar 19, 2021 · 5 comments

Comments

@Vignesh-dev12
Copy link

Vignesh-dev12 commented Mar 19, 2021

I need to get touch event in PDFView widget

Here my code

gestureRecognizers: {
     Factory<OneSequenceGestureRecognizer>(
            () => TapGestureRecognizer()
               ..onTap = () {
                 print("gestureRecognizers() onTap")
               })
},
@whutpsychic
Copy link

the same issue for me and i tried

gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>[
                new Factory<OneSequenceGestureRecognizer>(
                  () => new EagerGestureRecognizer(),
                ),
              ].toSet()

still not work for me on iOS

@whutpsychic
Copy link

whutpsychic commented May 19, 2021

oh,hell bro.I found the solution

 gestureRecognizers: Set()
                ..add(Factory<TapGestureRecognizer>(() => TapGestureRecognizer()
                  ..onTapDown = (tap) {
                    print("hell bro");
                  })),

but I found this handler will be a little slow to response.And sometimes it cannot be responded

@tomriddle7
Copy link

oh,hell bro.I found the solution

 gestureRecognizers: Set()
                ..add(Factory<TapGestureRecognizer>(() => TapGestureRecognizer()
                  ..onTapDown = (tap) {
                    print("hell bro");
                  })),

but I found this handler will be a little slow to response.And sometimes it cannot be responded

I tried same code but it didn't worked.

@The-Redhat
Copy link

I think is issue a flutter issue: flutter/flutter#52002

@chrisbinsunny
Copy link

I found a solution for the issue. I was checking for the presense of onTapDown and added

gestureRecognizers: Set()
        ..add(Factory<TapGestureRecognizer>(() => TapGestureRecognizer()
          ..onTapDown = (tap) {
            print("hell bro");
          })),

But, it didn't work somehow. I was checking for other solutions and thought to add GestureDetector and detect tap from that.

So, I just wrapped PDFView with a GestureDetector. Surprisingly, gestureRecognizers inside PDFView worked after adding GestureDetector() Widget. Since I was checking for onTapDown event with gestureRecognizers, I added onTap parameter in GestureDetector.

My Widget looked like this:

GestureDetector(
    onTap: (){}, //This has to be added. Won't work without this.
    child: PDFView(
      filePath: widget.link,
      onError: (error) {
        print(error.toString());
      },
      onPageError: (page, error) {
        print('$page: ${error.toString()}');
      },
      onViewCreated: (PDFViewController pdfViewController) {
        pdfController=pdfViewController;
      },
      onPageChanged: (a, b){
        visible=false;
      },
      gestureRecognizers: Set()
        ..add(Factory<TapGestureRecognizer>(() => TapGestureRecognizer()
          ..onTapDown = (tap) {
            print("Tap Down Gesture Detected");
          })),
    ),
  )

Hope that helps...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants