Flutter webveiw crash while asking location permission in webview

Viewed 70

I have integrated flutter_inappwebview in my app for a common webview, when there are some links which needs location permission my webview is closed or crashed.

Here is a code which I have done:

Container(
        height: MediaQuery.of(context).viewInsets.bottom == 0
            ? MediaQuery.of(context).size.height - 90
            : MediaQuery.of(context).size.height / 2 + 60,
        width: MediaQuery.of(context).size.width,
        child: InAppWebView(
          initialUrlRequest:
              URLRequest(url: Uri.parse("https://www.zomato.com/")),
          initialOptions: InAppWebViewGroupOptions(
            crossPlatform: InAppWebViewOptions(
              javaScriptEnabled: true,
              javaScriptCanOpenWindowsAutomatically: true,
              mediaPlaybackRequiresUserGesture: false,
            ),
            android: AndroidInAppWebViewOptions(
              geolocationEnabled: true,
              allowFileAccess: true,
            ),
          ),
          androidOnGeolocationPermissionsShowPrompt:
              (controller, origin) async {
            log("----------came into androidOnGeolocationPermissionsShowPrompt------------>>>>>>>>>>>>>>>>>>");
            await location.requestService();
            return GeolocationPermissionShowPromptResponse(
                origin: origin, allow: true, retain: true);
          },
          androidOnGeolocationPermissionsHidePrompt: (controller) {
            log("----------came into androidOnGeolocationPermissionsHidePrompt------------>>>>>>>>>>>>>>>>>>");
          },
          androidOnPermissionRequest: (InAppWebViewController controller,
              String origin, List<String> resources) async {
            log("--------came in androidOnPermissionRequest------->>>>>>>>>>>>>>>>");
            return PermissionRequestResponse(
                resources: resources,
                action: PermissionRequestResponseAction.GRANT);
          },
          gestureRecognizers: <Factory<OneSequenceGestureRecognizer>>{
            Factory<OneSequenceGestureRecognizer>(
              () => EagerGestureRecognizer(),
            ),
          },
          onLoadStart: (controller, url) async {
            log("-------url------->>>>>>>>>>>>>> $url");
            showLoading(context);
            if (url.toString().contains("whatsapp://send/")) {
              await launchUrl(url!);
            }
          },
          onLoadStop: (controller, url) {
            hideLoading(context);
          },
        ),
      ),

I am having this error in console

E/FrameEvents( 1943): updateAcquireFence: Did not find frame.
I/chatty  ( 1943): uid=10154 RenderThread identical 1 line
E/FrameEvents( 1943): updateAcquireFence: Did not find frame.
E/chromium( 1943): [ERROR:aw_browser_terminator.cc(125)] Renderer process (2649) crash detected (code -1).

Please help me out. Thanks in advance.

0 Answers
Related