Capture onTap on Webview and send the details

134

You can get this by this way. just use "navigationDelegate" method inside Webview.

              WebView(
                  initialUrl: provider.webUrl,
                  javascriptMode: JavascriptMode.unrestricted,
                  navigationDelegate: (action) {
                    if (action.url ==
                        "https://stackoverflow.com/users/login?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2f") {
                      return NavigationDecision.prevent;
                    } else {
                      return NavigationDecision.navigate;
                    }
                  },
                  debuggingEnabled: true,
                  gestureNavigationEnabled: true,
                )

If you want to Navigate all kind of pages then use

navigationDelegate: (NavigationRequest action) {
   return NavigationDecision.navigate;
}

and you can get navigated url

navigationDelegate: (action) {
  print(action.url);
}
Share:
134
faysal neowaz
Author by

faysal neowaz

Hello During my current role at HAL Technologies Ltd., I was charged with developing android based innovative solutions across a variety of software platforms. I was instrumental in developing total front-end solution for android device for MyCash (A mobile base financial service from Mercantile Bank). A digital KYC were implemented were a customer for the bank can open a bank account by using android mobile/device. In 2020, I developed a flutter based mobile application named covid-19 response 2020.Where, a user can get latest updated and precaution information regarding corona epidemic. Below, I have mentioned some of my highlighted successful project experience: Android based authentication, validation, bill payment for my-cash users. I worked as android based solution Developer. Android Based Mobile apps for Rema Tea Company limited. My duties were including design and implement android base application for receiving attendance and work amount from Rema tea workers and connect api to a web service. Technologies and languages I master: Flutter, Android , XML, SOAP, JAVA , JSON, GIT Experience with all stages of Android development process. I will bring to your company my years of experience and my drive for results and positive outcomes; I am prepared for the next challenge in my career and look forward to hearing from you. Best Regards, Name: Faysal Neowaz email: [email protected]

Updated on December 28, 2022

Comments

  • faysal neowaz
    faysal neowaz over 1 year

    Is there any to get the click event from webView or how i can get the current url if he url changed. or when the url changed need to reload the webview.

    Note: Not in Button click action

     Stack(
                children: [
        
        
                  WebView(
                    javascriptMode: JavascriptMode.unrestricted,
                    initialUrl: mainUrl,
                    onWebViewCreated: (WebViewController webViewController){
                      _controller.complete(webViewController);
                    },
                    onPageFinished: (url){
                      allJsfile();
        
                    },
                    
                  ),
                  GestureDetector(
        
                    onTapDown: (_) => print('webview onTapDown $_'),
                    onTapUp: (_) => print('webview onTapUp $_'),
                    onTap: () => print('webview onTap'),
                    child: Container(),
                  ),
                ],
              ),
    
    • Mol0ko
      Mol0ko about 3 years
      Hi! You want to get current url inside onTap handler of GestureDetector, right?
    • faysal neowaz
      faysal neowaz about 3 years
      yes. I want to get url if user click on webview navigate to other page then i want the url