From 2b335a3aeb0c4aaa38860d5fd09eaf2695155db9 Mon Sep 17 00:00:00 2001 From: maxmitz Date: Mon, 17 Mar 2025 16:03:55 +0100 Subject: [PATCH 1/3] fix: corrected spelling mistake in filename --- ...iew_example.screen.dart => in_app_webview_example.screen.dart} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename flutter_inappwebview/example/lib/{in_app_webiew_example.screen.dart => in_app_webview_example.screen.dart} (100%) diff --git a/flutter_inappwebview/example/lib/in_app_webiew_example.screen.dart b/flutter_inappwebview/example/lib/in_app_webview_example.screen.dart similarity index 100% rename from flutter_inappwebview/example/lib/in_app_webiew_example.screen.dart rename to flutter_inappwebview/example/lib/in_app_webview_example.screen.dart From bb6381f959821f670e999e3187ecc3a282de362f Mon Sep 17 00:00:00 2001 From: maxmitz Date: Mon, 17 Mar 2025 16:04:49 +0100 Subject: [PATCH 2/3] refactor: inappwebview example screen --- .../lib/in_app_webview_example.screen.dart | 42 ++++++------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/flutter_inappwebview/example/lib/in_app_webview_example.screen.dart b/flutter_inappwebview/example/lib/in_app_webview_example.screen.dart index 4acc6d966..59b09347a 100755 --- a/flutter_inappwebview/example/lib/in_app_webview_example.screen.dart +++ b/flutter_inappwebview/example/lib/in_app_webview_example.screen.dart @@ -83,11 +83,6 @@ class _InAppWebViewExampleScreenState extends State { ); } - @override - void dispose() { - super.dispose(); - } - @override Widget build(BuildContext context) { return Scaffold( @@ -125,20 +120,17 @@ class _InAppWebViewExampleScreenState extends State { initialSettings: settings, contextMenu: contextMenu, pullToRefreshController: pullToRefreshController, - onWebViewCreated: (controller) async { - webViewController = controller; - }, + onWebViewCreated: (controller) => + webViewController = controller, onLoadStart: (controller, url) { setState(() { this.url = url.toString(); urlController.text = this.url; }); }, - onPermissionRequest: (controller, request) { - return PermissionResponse( - resources: request.resources, - action: PermissionResponseAction.GRANT); - }, + onPermissionRequest: (_, request) => PermissionResponse( + resources: request.resources, + action: PermissionResponseAction.GRANT), shouldOverrideUrlLoading: (controller, navigationAction) async { var uri = navigationAction.request.url!; @@ -171,9 +163,8 @@ class _InAppWebViewExampleScreenState extends State { urlController.text = this.url; }); }, - onReceivedError: (controller, request, error) { - pullToRefreshController?.endRefreshing(); - }, + onReceivedError: (_, __, ___) => + pullToRefreshController?.endRefreshing(), onProgressChanged: (controller, progress) { if (progress == 100) { pullToRefreshController?.endRefreshing(); @@ -189,9 +180,8 @@ class _InAppWebViewExampleScreenState extends State { urlController.text = this.url; }); }, - onConsoleMessage: (controller, consoleMessage) { - print(consoleMessage); - }, + onConsoleMessage: (controller, consoleMessage) => + print(consoleMessage), ), progress < 1.0 ? LinearProgressIndicator(value: progress) @@ -201,24 +191,18 @@ class _InAppWebViewExampleScreenState extends State { ), ButtonBar( alignment: MainAxisAlignment.center, - children: [ + children: [ ElevatedButton( child: Icon(Icons.arrow_back), - onPressed: () { - webViewController?.goBack(); - }, + onPressed: () => webViewController?.goBack(), ), ElevatedButton( child: Icon(Icons.arrow_forward), - onPressed: () { - webViewController?.goForward(); - }, + onPressed: () => webViewController?.goForward(), ), ElevatedButton( child: Icon(Icons.refresh), - onPressed: () { - webViewController?.reload(); - }, + onPressed: () => webViewController?.reload(), ), ], ), From 38c70a864a23d6bb4d7e7359770980eb07c9b27a Mon Sep 17 00:00:00 2001 From: maxmitz Date: Mon, 17 Mar 2025 16:15:57 +0100 Subject: [PATCH 3/3] refactor: example InAppWebView --- .../example/lib/in_app_webview_example.screen.dart | 11 +++++------ flutter_inappwebview/example/lib/main.dart | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/flutter_inappwebview/example/lib/in_app_webview_example.screen.dart b/flutter_inappwebview/example/lib/in_app_webview_example.screen.dart index 59b09347a..5338b474f 100755 --- a/flutter_inappwebview/example/lib/in_app_webview_example.screen.dart +++ b/flutter_inappwebview/example/lib/in_app_webview_example.screen.dart @@ -122,7 +122,7 @@ class _InAppWebViewExampleScreenState extends State { pullToRefreshController: pullToRefreshController, onWebViewCreated: (controller) => webViewController = controller, - onLoadStart: (controller, url) { + onLoadStart: (_, url) { setState(() { this.url = url.toString(); urlController.text = this.url; @@ -131,8 +131,7 @@ class _InAppWebViewExampleScreenState extends State { onPermissionRequest: (_, request) => PermissionResponse( resources: request.resources, action: PermissionResponseAction.GRANT), - shouldOverrideUrlLoading: - (controller, navigationAction) async { + shouldOverrideUrlLoading: (_, navigationAction) async { var uri = navigationAction.request.url!; if (![ @@ -156,7 +155,7 @@ class _InAppWebViewExampleScreenState extends State { return NavigationActionPolicy.ALLOW; }, - onLoadStop: (controller, url) { + onLoadStop: (_, url) { pullToRefreshController?.endRefreshing(); setState(() { this.url = url.toString(); @@ -174,13 +173,13 @@ class _InAppWebViewExampleScreenState extends State { urlController.text = this.url; }); }, - onUpdateVisitedHistory: (controller, url, isReload) { + onUpdateVisitedHistory: (_, url, __) { setState(() { this.url = url.toString(); urlController.text = this.url; }); }, - onConsoleMessage: (controller, consoleMessage) => + onConsoleMessage: (_, consoleMessage) => print(consoleMessage), ), progress < 1.0 diff --git a/flutter_inappwebview/example/lib/main.dart b/flutter_inappwebview/example/lib/main.dart index 0a7802bd8..28cf35c5f 100755 --- a/flutter_inappwebview/example/lib/main.dart +++ b/flutter_inappwebview/example/lib/main.dart @@ -6,7 +6,7 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'package:flutter_inappwebview_example/chrome_safari_browser_example.screen.dart'; import 'package:flutter_inappwebview_example/headless_in_app_webview.screen.dart'; import 'package:flutter_inappwebview_example/in_app_browser_example.screen.dart'; -import 'package:flutter_inappwebview_example/in_app_webiew_example.screen.dart'; +import 'package:flutter_inappwebview_example/in_app_webview_example.screen.dart'; import 'package:flutter_inappwebview_example/web_authentication_session_example.screen.dart'; import 'package:pointer_interceptor/pointer_interceptor.dart';