Skip to content

Commit f57efa9

Browse files
committed
Upgrade Webview 3.0.4 -> 4.10.0
Webview upgraded to Android Webview 2.0+ and overhauled their architecture. Rewrote privacy_policy_page.dart to use modern webview standard. Controler details : - Unrestricted JavaScript - Prevent navigation (allow only piwigo privacy policy) - set only allowed url to Settings.privacyPolicyUrl
1 parent a4ab80d commit f57efa9

2 files changed

Lines changed: 14 additions & 13 deletions

File tree

lib/views/settings/privacy_policy_page.dart

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,23 @@ class PrivacyPolicyPage extends StatefulWidget {
1313
}
1414

1515
class _PrivacyPolicyPageState extends State<PrivacyPolicyPage> {
16-
late final String _url;
16+
final controller = WebViewController();
1717

1818
@override
1919
void initState() {
20-
WebView.platform = AndroidWebView();
21-
_url = Settings.privacyPolicyUrl;
20+
controller
21+
..setJavaScriptMode(JavaScriptMode.unrestricted)
22+
..setNavigationDelegate(
23+
NavigationDelegate(
24+
onNavigationRequest: (NavigationRequest request) {
25+
return NavigationDecision.prevent;
26+
}
27+
),
28+
)
29+
..loadRequest(Uri.parse(Settings.privacyPolicyUrl));
2230
super.initState();
2331
}
2432

25-
NavigationDecision _navigation(NavigationRequest request) {
26-
return NavigationDecision.prevent;
27-
}
28-
2933
@override
3034
Widget build(BuildContext context) {
3135
return Scaffold(
@@ -39,10 +43,7 @@ class _PrivacyPolicyPageState extends State<PrivacyPolicyPage> {
3943
),
4044
body: Stack(
4145
children: [
42-
WebView(
43-
initialUrl: _url + appStrings.settings_privacyLocale,
44-
navigationDelegate: _navigation,
45-
),
46+
WebViewWidget(controller: controller),
4647
],
4748
),
4849
);

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ dependencies:
1515

1616
# Network
1717
url_launcher: ^6.1.5 # Open links with device's applications
18-
webview_flutter: ^3.0.4 # Show web page (CGU)
18+
webview_flutter: ^4.10.0 # Show web page (CGU)
1919
dio: ^5.4.3+1 # Requests to API
2020
dio_cookie_manager: ^2.0.0 # Compatibility between dio and cookie_far
2121
cookie_jar: ^3.0.1 # Handles cookies
@@ -48,7 +48,7 @@ dependencies:
4848
file_picker: ^8.3.7 # Pick images and videos at a time for upload
4949

5050
# Device
51-
device_info_plus: ^10.1.0 # Get device info (version)
51+
device_info_plus: ^10.1.0 # Get device info (version
5252
flutter_local_notifications: ^17.2.4 # Throws notifications on download or upload
5353
open_filex: ^4.4.0 # Open files with devices apps
5454
workmanager: ^0.5.2 # Background processes (auto upload)

0 commit comments

Comments
 (0)