Example: gps access is not granted or was denied
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () => _exitApp(context),
child: SafeArea(
child: Container(
child: InAppWebView(
initialUrl: "https://yumyum.delivery/",
initialOptions: InAppWebViewGroupOptions(
android: AndroidInAppWebViewOptions(
geolocationEnabled: true,
allowContentAccess: true,
builtInZoomControls: true,
thirdPartyCookiesEnabled: true,
allowFileAccess: true,
supportMultipleWindows: true),
crossPlatform: InAppWebViewOptions(
verticalScrollBarEnabled: true,
userAgent:
"Mozilla/5.0 (Linux; Android 9; LG-H870 Build/PKQ1.190522.001) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/83.0.4103.106 Mobile Safari/537.36",
clearCache: true,
disableContextMenu: false,
cacheEnabled: true,
javaScriptEnabled: true,
javaScriptCanOpenWindowsAutomatically: true,
debuggingEnabled: true,
transparentBackground: true,
),
),
onWebViewCreated: (InAppWebViewController controller) {
webView = controller;
},
onCreateWindow: (controller, createWindowRequest) async {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
content: Container(
width: MediaQuery.of(context).size.width,
height: 400,
child: InAppWebView(
// Setting the windowId property is important here!
windowId: createWindowRequest.windowId,
initialOptions: InAppWebViewGroupOptions(
android: AndroidInAppWebViewOptions(
builtInZoomControls: true,
thirdPartyCookiesEnabled: true,
),
crossPlatform: InAppWebViewOptions(
cacheEnabled: true,
javaScriptEnabled: true,
debuggingEnabled: true,
userAgent:
"Mozilla/5.0 (Linux; Android 9; LG-H870 Build/PKQ1.190522.001) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/83.0.4103.106 Mobile Safari/537.36"),
),
onWebViewCreated:
(InAppWebViewController controller) {},
onLoadStart:
(InAppWebViewController controller, String url) {
print("onLoadStart popup $url");
},
onLoadStop: (InAppWebViewController controller,
String url) async {
print("onLoadStop popup $url");
},
onCloseWindow: (controller) {
// On Facebook Login, this event is called twice,
// so here we check if we already popped the alert dialog context
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
},
),
),
);
},
);
return true;
},
),
),
),
);
}