File tree Expand file tree Collapse file tree 4 files changed +47
-1
lines changed
packages/webview_flutter/webview_flutter_android Expand file tree Collapse file tree 4 files changed +47
-1
lines changed Original file line number Diff line number Diff line change
1
+ ## 4.10.4
2
+
3
+ * Adds a README section about enabling geolocation.
4
+
1
5
## 4.10.3
2
6
3
7
* Updates Java compatibility version to 17.
Original file line number Diff line number Diff line change @@ -106,6 +106,29 @@ androidController.setCustomWidgetCallbacks(
106
106
);
107
107
```
108
108
109
+ ## Geolocation
110
+
111
+ By default, WebView does not allow geolocation requests. To allow them, call
112
+ ` setGeolocationPermissionsPromptCallbacks ` on the ` AndroidWebViewController ` to
113
+ configure a prompt handler. For example, to unconditionally allow all requests:
114
+
115
+ <? code-excerpt "example/lib/readme_excerpts.dart (geolocation_example)"?>
116
+ ``` dart
117
+ await androidController.setGeolocationPermissionsPromptCallbacks(
118
+ onShowPrompt: (GeolocationPermissionsRequestParams request) async {
119
+ return const GeolocationPermissionsResponse(allow: true, retain: true);
120
+ },
121
+ );
122
+ ```
123
+
124
+ ** Important:** Geolocation requests should only be allowed unconditionally if
125
+ the web view content is restricted to domains you control or trust. If you are
126
+ showing untrusted content, the ` onShowPrompt ` implementation should request
127
+ permission from the user before responding.
128
+
129
+ Your application must have geolocation permissions granted in order for the
130
+ WebView to have access to geolocation.
131
+
109
132
## Contributing
110
133
111
134
For information on contributing to this plugin, see [ ` CONTRIBUTING.md ` ] ( CONTRIBUTING.md ) .
Original file line number Diff line number Diff line change @@ -21,3 +21,22 @@ Future<void> enablePaymentRequest() async {
21
21
}
22
22
// #enddocregion payment_request_example
23
23
}
24
+
25
+ /// Example function for README demonstration of geolocation permissions for
26
+ /// a use case where the content is always trusted (for example, it only shows
27
+ /// content from a domain controlled by the app developer) and geolocation
28
+ /// should always be allowed.
29
+ Future <void > setGeolocationPermissionsPrompt () async {
30
+ final PlatformWebViewController controller = PlatformWebViewController (
31
+ AndroidWebViewControllerCreationParams (),
32
+ );
33
+ final AndroidWebViewController androidController =
34
+ controller as AndroidWebViewController ;
35
+ // #docregion geolocation_example
36
+ await androidController.setGeolocationPermissionsPromptCallbacks (
37
+ onShowPrompt: (GeolocationPermissionsRequestParams request) async {
38
+ return const GeolocationPermissionsResponse (allow: true , retain: true );
39
+ },
40
+ );
41
+ // #enddocregion geolocation_example
42
+ }
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ name: webview_flutter_android
2
2
description : A Flutter plugin that provides a WebView widget on Android.
3
3
repository : https://github.com/flutter/packages/tree/main/packages/webview_flutter/webview_flutter_android
4
4
issue_tracker : https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+webview%22
5
- version : 4.10.3
5
+ version : 4.10.4
6
6
7
7
environment :
8
8
sdk : ^3.9.0
You can’t perform that action at this time.
0 commit comments