From 9cb8b3af26ce82f93c6f1c04589b7e52b25c8471 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Thu, 23 Nov 2023 16:01:14 +0100 Subject: [PATCH] updated chrome_safari_browser implementation, updated WebMessage.ports interface, updated WebViewAssetLoader implementation, force InAppWebViewController type for webview controller events --- .../chrome_safari_browser/custom_tabs.dart | 4 +- .../sf_safari_view_controller.dart | 4 +- .../cookie_manager/set_get_delete.dart | 4 +- .../convert_to_inappwebview.dart | 12 +- .../headless_in_app_webview/custom_size.dart | 4 +- .../run_and_dispose.dart | 6 +- .../set_get_settings.dart | 6 +- .../take_screenshot.dart | 6 +- .../load_asset_file.dart | 6 +- .../in_app_webview/audio_playback_policy.dart | 8 +- .../in_app_webview/clear_cache.dart | 6 +- .../in_app_webview/clear_focus.dart | 6 +- .../in_app_webview/clear_ssl_preferences.dart | 6 +- .../in_app_webview/content_blocker.dart | 4 +- .../in_app_webview/create_pdf.dart | 6 +- .../in_app_webview/get_certificate.dart | 6 +- .../in_app_webview/get_content_height.dart | 6 +- .../in_app_webview/get_favicons.dart | 6 +- .../in_app_webview/get_html.dart | 6 +- .../in_app_webview/get_meta_tags.dart | 6 +- .../in_app_webview/get_meta_theme_color.dart | 6 +- .../in_app_webview/get_original_url.dart | 6 +- .../in_app_webview/get_progress.dart | 6 +- .../in_app_webview/get_title.dart | 6 +- .../http_auth_credential_database.dart | 12 +- .../in_app_webview/initial_url_request.dart | 12 +- .../in_app_webview/inject_css.dart | 18 +- .../inject_javascript_file.dart | 12 +- .../intercept_ajax_request.dart | 16 +- .../intercept_fetch_request.dart | 16 +- .../in_app_webview/is_loading.dart | 6 +- .../in_app_webview/is_secure_context.dart | 6 +- .../javascript_code_evaluation.dart | 24 +- .../in_app_webview/javascript_dialogs.dart | 4 +- .../in_app_webview/javascript_handler.dart | 4 +- .../in_app_webview/keep_alive.dart | 12 +- .../in_app_webview/load_data.dart | 6 +- .../in_app_webview/load_file.dart | 6 +- .../in_app_webview/load_url.dart | 12 +- .../in_app_webview/on_console_message.dart | 4 +- .../on_download_start_request.dart | 4 +- .../in_app_webview/on_js_before_unload.dart | 4 +- .../on_load_resource_with_custom_scheme.dart | 4 +- .../on_navigation_response.dart | 8 +- .../on_page_commit_visible.dart | 4 +- .../in_app_webview/on_permission_request.dart | 12 +- .../in_app_webview/on_received_icon.dart | 4 +- .../on_received_touch_icon_url.dart | 4 +- .../in_app_webview/on_scroll_changed.dart | 6 +- .../in_app_webview/on_title_changed.dart | 6 +- .../on_update_visited_history.dart | 6 +- .../in_app_webview/page_down_up.dart | 6 +- .../in_app_webview/pause_resume.dart | 6 +- .../in_app_webview/pause_resume_timers.dart | 6 +- .../in_app_webview/post_requests.dart | 18 +- .../in_app_webview/print_current_page.dart | 6 +- .../in_app_webview/programmatic_scroll.dart | 12 +- .../programmatic_zoom_scale.dart | 24 +- .../in_app_webview/pull_to_refresh.dart | 6 +- .../in_app_webview/reload.dart | 12 +- .../request_focus_node_href.dart | 6 +- .../in_app_webview/request_image_ref.dart | 6 +- .../in_app_webview/resize_webview.dart | 4 +- .../in_app_webview/set_custom_useragent.dart | 2 +- .../in_app_webview/set_get_settings.dart | 6 +- .../should_intercept_request.dart | 4 +- .../should_override_url_loading.dart | 24 +- .../in_app_webview/ssl_request.dart | 6 +- .../in_app_webview/stop_loading.dart | 6 +- .../in_app_webview/t_rex_runner_game.dart | 4 +- .../in_app_webview/take_screenshot.dart | 6 +- .../in_app_webview/user_scripts.dart | 12 +- .../in_app_webview/video_playback_policy.dart | 22 +- .../in_app_webview/web_archive.dart | 12 +- .../in_app_webview/web_history.dart | 18 +- .../in_app_webview/web_message.dart | 20 +- .../in_app_webview/webview_asset_loader.dart | 8 +- .../in_app_webview/webview_windows.dart | 34 +- .../clear_and_set_proxy_override.dart | 6 +- example/integration_test/util.dart | 2 +- .../webview_flutter_test.dart | 16 +- .../chrome_safari_browser_example.screen.dart | 4 +- example/lib/in_app_webiew_example.screen.dart | 2 +- .../chrome_safari_browser.dart | 600 +++++++++++++++++ .../lib/src/chrome_safari_browser/main.dart | 1 + .../lib/src/cookie_manager.dart | 2 +- .../headless_in_app_webview.dart | 12 +- .../src/in_app_webview/in_app_webview.dart | 50 +- .../in_app_webview_controller.dart | 586 +++++++++-------- .../lib/src/inappwebview_platform.dart | 86 +-- .../lib/src/main.dart | 7 +- .../lib/src/webview_asset_loader.dart | 127 +--- .../platform_chrome_safari_browser.dart | 444 ++++--------- .../platform_in_app_browser.dart | 5 +- .../in_app_webview_settings.dart | 15 +- .../in_app_webview_settings.g.dart | 8 +- .../platform_headless_in_app_webview.dart | 251 +++---- .../platform_inappwebview_widget.dart | 245 +++---- .../src/in_app_webview/platform_webview.dart | 169 ++--- .../lib/src/inappwebview_platform.dart | 41 +- .../src/platform_webview_asset_loader.dart | 101 +-- .../src/platform_webview_asset_loader.g.dart | 78 +++ .../platform_web_message_port.dart | 33 +- .../lib/src/web_message/web_message.dart | 2 +- .../lib/src/web_message/web_message.g.dart | 4 +- .../chrome_safari_browser.dart | 398 +++-------- .../headless_in_app_webview.dart | 616 ++++++++++++------ lib/src/in_app_webview/in_app_webview.dart | 584 ++++++++++++----- lib/src/web_message/web_message_port.dart | 2 +- lib/src/webview_asset_loader.dart | 82 +-- pubspec.yaml | 2 +- 111 files changed, 2914 insertions(+), 2337 deletions(-) create mode 100755 flutter_inappwebview_android/lib/src/chrome_safari_browser/chrome_safari_browser.dart create mode 100644 flutter_inappwebview_android/lib/src/chrome_safari_browser/main.dart create mode 100644 flutter_inappwebview_platform_interface/lib/src/platform_webview_asset_loader.g.dart diff --git a/example/integration_test/chrome_safari_browser/custom_tabs.dart b/example/integration_test/chrome_safari_browser/custom_tabs.dart index 104914cb..d62bdd88 100644 --- a/example/integration_test/chrome_safari_browser/custom_tabs.dart +++ b/example/integration_test/chrome_safari_browser/custom_tabs.dart @@ -214,12 +214,12 @@ void customTabs() { }); skippableTest('getMaxToolbarItems', () async { - expect(await PlatformChromeSafariBrowser.getMaxToolbarItems(), + expect(await ChromeSafariBrowser.getMaxToolbarItems(), greaterThanOrEqualTo(0)); }); skippableTest('getPackageName', () async { - expect(await PlatformChromeSafariBrowser.getPackageName(), isNotNull); + expect(await ChromeSafariBrowser.getPackageName(), isNotNull); }); }, skip: shouldSkip); } diff --git a/example/integration_test/chrome_safari_browser/sf_safari_view_controller.dart b/example/integration_test/chrome_safari_browser/sf_safari_view_controller.dart index 1dd11bfe..c4579d67 100644 --- a/example/integration_test/chrome_safari_browser/sf_safari_view_controller.dart +++ b/example/integration_test/chrome_safari_browser/sf_safari_view_controller.dart @@ -32,10 +32,10 @@ void sfSafariViewController() { skippableTest('create and invalidate Prewarming Token', () async { final prewarmingToken = - await PlatformChromeSafariBrowser.prewarmConnections([TEST_URL_1]); + await ChromeSafariBrowser.prewarmConnections([TEST_URL_1]); expect(prewarmingToken, isNotNull); await expectLater( - PlatformChromeSafariBrowser.invalidatePrewarmingToken(prewarmingToken!), + ChromeSafariBrowser.invalidatePrewarmingToken(prewarmingToken!), completes); }); }, skip: shouldSkip); diff --git a/example/integration_test/cookie_manager/set_get_delete.dart b/example/integration_test/cookie_manager/set_get_delete.dart index 8a9f499b..fafc4ec7 100644 --- a/example/integration_test/cookie_manager/set_get_delete.dart +++ b/example/integration_test/cookie_manager/set_get_delete.dart @@ -11,8 +11,8 @@ void setGetDelete() { skippableTestWidgets('set, get, delete', (WidgetTester tester) async { CookieManager cookieManager = CookieManager.instance(); - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); var headlessWebView = new HeadlessInAppWebView( diff --git a/example/integration_test/headless_in_app_webview/convert_to_inappwebview.dart b/example/integration_test/headless_in_app_webview/convert_to_inappwebview.dart index 2dee496c..1c396575 100644 --- a/example/integration_test/headless_in_app_webview/convert_to_inappwebview.dart +++ b/example/integration_test/headless_in_app_webview/convert_to_inappwebview.dart @@ -9,8 +9,8 @@ void convertToInAppWebView() { ].contains(defaultTargetPlatform); skippableTestWidgets('convert to InAppWebView', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); var headlessWebView = new HeadlessInAppWebView( @@ -26,14 +26,14 @@ void convertToInAppWebView() { await headlessWebView.run(); expect(headlessWebView.isRunning(), true); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; final String? url = (await controller.getUrl())?.toString(); expect(url, TEST_CROSS_PLATFORM_URL_1.toString()); - final Completer widgetControllerCompleter = - Completer(); + final Completer widgetControllerCompleter = + Completer(); final Completer loadedUrl = Completer(); await tester.pumpWidget( @@ -54,7 +54,7 @@ void convertToInAppWebView() { ), ), ); - final PlatformInAppWebViewController widgetController = + final InAppWebViewController widgetController = await widgetControllerCompleter.future; expect(headlessWebView.isRunning(), false); diff --git a/example/integration_test/headless_in_app_webview/custom_size.dart b/example/integration_test/headless_in_app_webview/custom_size.dart index 34b997dc..2147408d 100644 --- a/example/integration_test/headless_in_app_webview/custom_size.dart +++ b/example/integration_test/headless_in_app_webview/custom_size.dart @@ -10,8 +10,8 @@ void customSize() { ].contains(defaultTargetPlatform); skippableTest('set and get custom size', () async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); var headlessWebView = new HeadlessInAppWebView( initialUrlRequest: URLRequest(url: TEST_CROSS_PLATFORM_URL_1), diff --git a/example/integration_test/headless_in_app_webview/run_and_dispose.dart b/example/integration_test/headless_in_app_webview/run_and_dispose.dart index 21576b9c..33dad366 100644 --- a/example/integration_test/headless_in_app_webview/run_and_dispose.dart +++ b/example/integration_test/headless_in_app_webview/run_and_dispose.dart @@ -10,8 +10,8 @@ void runAndDispose() { ].contains(defaultTargetPlatform); skippableTest('run and dispose', () async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); var headlessWebView = new HeadlessInAppWebView( @@ -27,7 +27,7 @@ void runAndDispose() { await headlessWebView.run(); expect(headlessWebView.isRunning(), true); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; final String? url = (await controller.getUrl())?.toString(); diff --git a/example/integration_test/headless_in_app_webview/set_get_settings.dart b/example/integration_test/headless_in_app_webview/set_get_settings.dart index a1cf6adf..07489aff 100644 --- a/example/integration_test/headless_in_app_webview/set_get_settings.dart +++ b/example/integration_test/headless_in_app_webview/set_get_settings.dart @@ -10,8 +10,8 @@ void setGetSettings() { ].contains(defaultTargetPlatform); skippableTest('set/get settings', () async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); var headlessWebView = new HeadlessInAppWebView( @@ -26,7 +26,7 @@ void setGetSettings() { ); await headlessWebView.run(); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; var settings = await controller.getSettings(); diff --git a/example/integration_test/headless_in_app_webview/take_screenshot.dart b/example/integration_test/headless_in_app_webview/take_screenshot.dart index aee83224..5009e47f 100644 --- a/example/integration_test/headless_in_app_webview/take_screenshot.dart +++ b/example/integration_test/headless_in_app_webview/take_screenshot.dart @@ -9,8 +9,8 @@ void takeScreenshot() { ].contains(defaultTargetPlatform); skippableTest('take screenshot', () async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); var headlessWebView = new HeadlessInAppWebView( @@ -27,7 +27,7 @@ void takeScreenshot() { await headlessWebView.run(); expect(headlessWebView.isRunning(), true); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; final String? url = (await controller.getUrl())?.toString(); diff --git a/example/integration_test/in_app_localhost_server/load_asset_file.dart b/example/integration_test/in_app_localhost_server/load_asset_file.dart index e80d82e4..8b84625f 100644 --- a/example/integration_test/in_app_localhost_server/load_asset_file.dart +++ b/example/integration_test/in_app_localhost_server/load_asset_file.dart @@ -12,8 +12,8 @@ void loadAssetFile(InAppLocalhostServer localhostServer) { skippableTestWidgets('load asset file', (WidgetTester tester) async { expect(localhostServer.isRunning(), true); - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); var headlessWebView = new HeadlessInAppWebView( initialUrlRequest: URLRequest( @@ -40,7 +40,7 @@ void loadAssetFile(InAppLocalhostServer localhostServer) { ), ); } - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; final String? currentUrl = (await controller.getUrl())?.toString(); expect(currentUrl, 'http://localhost:8080/test_assets/index.html'); diff --git a/example/integration_test/in_app_webview/audio_playback_policy.dart b/example/integration_test/in_app_webview/audio_playback_policy.dart index ab90cb60..0176047d 100644 --- a/example/integration_test/in_app_webview/audio_playback_policy.dart +++ b/example/integration_test/in_app_webview/audio_playback_policy.dart @@ -41,8 +41,8 @@ void audioPlaybackPolicy() { }); skippableTestWidgets('Auto media playback', (WidgetTester tester) async { - Completer controllerCompleter = - Completer(); + Completer controllerCompleter = + Completer(); Completer pageStarted = Completer(); Completer pageLoaded = Completer(); @@ -69,7 +69,7 @@ void audioPlaybackPolicy() { ), ), ); - PlatformInAppWebViewController controller = await controllerCompleter.future; + InAppWebViewController controller = await controllerCompleter.future; await pageStarted.future; await pageLoaded.future; @@ -77,7 +77,7 @@ void audioPlaybackPolicy() { await controller.evaluateJavascript(source: 'isPaused();'); expect(isPaused, false); - controllerCompleter = Completer(); + controllerCompleter = Completer(); pageStarted = Completer(); pageLoaded = Completer(); diff --git a/example/integration_test/in_app_webview/clear_cache.dart b/example/integration_test/in_app_webview/clear_cache.dart index fc608c77..8c4ece5b 100644 --- a/example/integration_test/in_app_webview/clear_cache.dart +++ b/example/integration_test/in_app_webview/clear_cache.dart @@ -10,8 +10,8 @@ void clearCache() { ].contains(defaultTargetPlatform); skippableTestWidgets('clearCache', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -30,7 +30,7 @@ void clearCache() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await expectLater(controller.clearCache(), completes); }, skip: shouldSkip); diff --git a/example/integration_test/in_app_webview/clear_focus.dart b/example/integration_test/in_app_webview/clear_focus.dart index 9bc18861..e961bcf3 100644 --- a/example/integration_test/in_app_webview/clear_focus.dart +++ b/example/integration_test/in_app_webview/clear_focus.dart @@ -10,8 +10,8 @@ void clearFocus() { ].contains(defaultTargetPlatform); skippableTestWidgets('clearFocus', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -30,7 +30,7 @@ void clearFocus() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await expectLater(controller.clearFocus(), completes); diff --git a/example/integration_test/in_app_webview/clear_ssl_preferences.dart b/example/integration_test/in_app_webview/clear_ssl_preferences.dart index fc06075b..c02c2714 100644 --- a/example/integration_test/in_app_webview/clear_ssl_preferences.dart +++ b/example/integration_test/in_app_webview/clear_ssl_preferences.dart @@ -8,8 +8,8 @@ void clearSslPreferences() { ].contains(defaultTargetPlatform); skippableTestWidgets('clearSslPreferences', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -28,7 +28,7 @@ void clearSslPreferences() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await expectLater(controller.clearSslPreferences(), completes); }, skip: shouldSkip); diff --git a/example/integration_test/in_app_webview/content_blocker.dart b/example/integration_test/in_app_webview/content_blocker.dart index f6ed13db..03ba8060 100644 --- a/example/integration_test/in_app_webview/content_blocker.dart +++ b/example/integration_test/in_app_webview/content_blocker.dart @@ -10,8 +10,8 @@ void contentBlocker() { ].contains(defaultTargetPlatform); skippableTestWidgets('Content Blocker', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( Directionality( diff --git a/example/integration_test/in_app_webview/create_pdf.dart b/example/integration_test/in_app_webview/create_pdf.dart index ce685ce6..acf78371 100644 --- a/example/integration_test/in_app_webview/create_pdf.dart +++ b/example/integration_test/in_app_webview/create_pdf.dart @@ -9,8 +9,8 @@ void createPdf() { ].contains(defaultTargetPlatform); skippableTestWidgets('createPdf', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -29,7 +29,7 @@ void createPdf() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; var pdfConfiguration = PDFConfiguration( diff --git a/example/integration_test/in_app_webview/get_certificate.dart b/example/integration_test/in_app_webview/get_certificate.dart index d96f1121..fc43fef6 100644 --- a/example/integration_test/in_app_webview/get_certificate.dart +++ b/example/integration_test/in_app_webview/get_certificate.dart @@ -10,8 +10,8 @@ void getCertificate() { ].contains(defaultTargetPlatform); skippableTestWidgets('getCertificate', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -30,7 +30,7 @@ void getCertificate() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; var sslCertificate = await controller.getCertificate(); diff --git a/example/integration_test/in_app_webview/get_content_height.dart b/example/integration_test/in_app_webview/get_content_height.dart index 7e773ee0..1e1635fc 100644 --- a/example/integration_test/in_app_webview/get_content_height.dart +++ b/example/integration_test/in_app_webview/get_content_height.dart @@ -12,8 +12,8 @@ void getContentHeight() { var url = !kIsWeb ? TEST_CROSS_PLATFORM_URL_1 : TEST_WEB_PLATFORM_URL_1; skippableTestWidgets('getContentHeight', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -32,7 +32,7 @@ void getContentHeight() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await tester.pump(); diff --git a/example/integration_test/in_app_webview/get_favicons.dart b/example/integration_test/in_app_webview/get_favicons.dart index 20f05881..d2ff44a2 100644 --- a/example/integration_test/in_app_webview/get_favicons.dart +++ b/example/integration_test/in_app_webview/get_favicons.dart @@ -12,8 +12,8 @@ void getFavicons() { var url = !kIsWeb ? TEST_CROSS_PLATFORM_URL_1 : TEST_WEB_PLATFORM_URL_1; skippableTestWidgets('getFavicons', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -32,7 +32,7 @@ void getFavicons() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; final List? favicons = await controller.getFavicons(); diff --git a/example/integration_test/in_app_webview/get_html.dart b/example/integration_test/in_app_webview/get_html.dart index 6d764ecf..a6230478 100644 --- a/example/integration_test/in_app_webview/get_html.dart +++ b/example/integration_test/in_app_webview/get_html.dart @@ -12,8 +12,8 @@ void getHtml() { var url = !kIsWeb ? TEST_CROSS_PLATFORM_URL_1 : TEST_WEB_PLATFORM_URL_1; skippableTestWidgets('getHtml', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -32,7 +32,7 @@ void getHtml() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; final String? html = await controller.getHtml(); diff --git a/example/integration_test/in_app_webview/get_meta_tags.dart b/example/integration_test/in_app_webview/get_meta_tags.dart index 984cbccb..e30b703e 100644 --- a/example/integration_test/in_app_webview/get_meta_tags.dart +++ b/example/integration_test/in_app_webview/get_meta_tags.dart @@ -12,8 +12,8 @@ void getMetaTags() { var url = !kIsWeb ? TEST_CROSS_PLATFORM_URL_1 : TEST_WEB_PLATFORM_URL_1; skippableTestWidgets('getMetaTags', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -32,7 +32,7 @@ void getMetaTags() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; List metaTags = await controller.getMetaTags(); diff --git a/example/integration_test/in_app_webview/get_meta_theme_color.dart b/example/integration_test/in_app_webview/get_meta_theme_color.dart index 70a7648d..15f8fe86 100644 --- a/example/integration_test/in_app_webview/get_meta_theme_color.dart +++ b/example/integration_test/in_app_webview/get_meta_theme_color.dart @@ -12,8 +12,8 @@ void getMetaThemeColor() { var url = !kIsWeb ? TEST_URL_1 : TEST_WEB_PLATFORM_URL_1; skippableTestWidgets('getMetaThemeColor', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -32,7 +32,7 @@ void getMetaThemeColor() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; expect(await controller.getMetaThemeColor(), isNotNull); diff --git a/example/integration_test/in_app_webview/get_original_url.dart b/example/integration_test/in_app_webview/get_original_url.dart index f98aba25..635e95d9 100644 --- a/example/integration_test/in_app_webview/get_original_url.dart +++ b/example/integration_test/in_app_webview/get_original_url.dart @@ -12,8 +12,8 @@ void getOriginalUrl() { var url = !kIsWeb ? TEST_URL_1 : TEST_WEB_PLATFORM_URL_1; skippableTestWidgets('getOriginalUrl', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -32,7 +32,7 @@ void getOriginalUrl() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; var originUrl = (await controller.getOriginalUrl())?.toString(); expect(originUrl, url.toString()); diff --git a/example/integration_test/in_app_webview/get_progress.dart b/example/integration_test/in_app_webview/get_progress.dart index 28192ad9..e550307c 100644 --- a/example/integration_test/in_app_webview/get_progress.dart +++ b/example/integration_test/in_app_webview/get_progress.dart @@ -10,8 +10,8 @@ void getProgress() { ].contains(defaultTargetPlatform); skippableTestWidgets('getProgress', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -30,7 +30,7 @@ void getProgress() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; final int? progress = await controller.getProgress(); diff --git a/example/integration_test/in_app_webview/get_title.dart b/example/integration_test/in_app_webview/get_title.dart index 37e718bd..dcd49224 100644 --- a/example/integration_test/in_app_webview/get_title.dart +++ b/example/integration_test/in_app_webview/get_title.dart @@ -28,8 +28,8 @@ void getTitle() { skippableTestWidgets('getTitle', (WidgetTester tester) async { final Completer pageStarted = Completer(); final Completer pageLoaded = Completer(); - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); await tester.pumpWidget( Directionality( @@ -49,7 +49,7 @@ void getTitle() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageStarted.future; await pageLoaded.future; diff --git a/example/integration_test/in_app_webview/http_auth_credential_database.dart b/example/integration_test/in_app_webview/http_auth_credential_database.dart index fb0bda56..fc1ebef5 100644 --- a/example/integration_test/in_app_webview/http_auth_credential_database.dart +++ b/example/integration_test/in_app_webview/http_auth_credential_database.dart @@ -13,8 +13,8 @@ void httpAuthCredentialDatabase() { skippableTestWidgets('use saved credentials', (WidgetTester tester) async { HttpAuthCredentialDatabase httpAuthCredentialDatabase = HttpAuthCredentialDatabase.instance(); - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); httpAuthCredentialDatabase.setHttpAuthCredential( @@ -50,7 +50,7 @@ void httpAuthCredentialDatabase() { ), ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; @@ -77,8 +77,8 @@ void httpAuthCredentialDatabase() { }); skippableTestWidgets('save credentials', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -107,7 +107,7 @@ void httpAuthCredentialDatabase() { ), ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; diff --git a/example/integration_test/in_app_webview/initial_url_request.dart b/example/integration_test/in_app_webview/initial_url_request.dart index 1629eb0c..792467b3 100644 --- a/example/integration_test/in_app_webview/initial_url_request.dart +++ b/example/integration_test/in_app_webview/initial_url_request.dart @@ -21,8 +21,8 @@ void initialUrlRequest() { 'launches with allowsBackForwardNavigationGestures true', (WidgetTester tester) async { final Completer pageLoaded = Completer(); - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); await tester.pumpWidget( Directionality( @@ -46,7 +46,7 @@ void initialUrlRequest() { ), ); await pageLoaded.future; - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; final String? currentUrl = (await controller.getUrl())?.toString(); expect(currentUrl, TEST_URL_1.toString()); @@ -62,8 +62,8 @@ void initialUrlRequest() { skippableTestWidgets('basic', (WidgetTester tester) async { final Completer pageLoaded = Completer(); - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); await tester.pumpWidget( Directionality( @@ -82,7 +82,7 @@ void initialUrlRequest() { ); await pageLoaded.future; - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; final String? currentUrl = (await controller.getUrl())?.toString(); diff --git a/example/integration_test/in_app_webview/inject_css.dart b/example/integration_test/in_app_webview/inject_css.dart index 238ad8b9..cb556394 100644 --- a/example/integration_test/in_app_webview/inject_css.dart +++ b/example/integration_test/in_app_webview/inject_css.dart @@ -13,8 +13,8 @@ void injectCSS() { skippableGroup('inject CSS', () { skippableTestWidgets('code', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -33,7 +33,7 @@ void injectCSS() { ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; @@ -52,8 +52,8 @@ void injectCSS() { }); skippableTestWidgets('file from url', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -72,7 +72,7 @@ void injectCSS() { ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; @@ -88,8 +88,8 @@ void injectCSS() { }); skippableTestWidgets('file from asset', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -108,7 +108,7 @@ void injectCSS() { ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; diff --git a/example/integration_test/in_app_webview/inject_javascript_file.dart b/example/integration_test/in_app_webview/inject_javascript_file.dart index 01d4b2a1..1f60b5c0 100644 --- a/example/integration_test/in_app_webview/inject_javascript_file.dart +++ b/example/integration_test/in_app_webview/inject_javascript_file.dart @@ -13,8 +13,8 @@ void injectJavascriptFile() { skippableGroup('inject javascript file', () { skippableTestWidgets('from url', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); final Completer jQueryLoaded = Completer(); final Completer jQueryLoadError = Completer(); @@ -35,7 +35,7 @@ void injectJavascriptFile() { ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; @@ -75,8 +75,8 @@ void injectJavascriptFile() { }); skippableTestWidgets('from asset', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -95,7 +95,7 @@ void injectJavascriptFile() { ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; diff --git a/example/integration_test/in_app_webview/intercept_ajax_request.dart b/example/integration_test/in_app_webview/intercept_ajax_request.dart index 8d45bc5f..dfcec00b 100644 --- a/example/integration_test/in_app_webview/intercept_ajax_request.dart +++ b/example/integration_test/in_app_webview/intercept_ajax_request.dart @@ -11,8 +11,8 @@ void interceptAjaxRequest() { skippableGroup('intercept ajax request', () { skippableTestWidgets('send string data', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer shouldInterceptAjaxPostRequestCompleter = Completer(); final Completer> onAjaxReadyStateChangeCompleter = @@ -93,8 +93,8 @@ void interceptAjaxRequest() { }); skippableTestWidgets('send json data', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer shouldInterceptAjaxPostRequestCompleter = Completer(); final Completer> onAjaxReadyStateChangeCompleter = @@ -182,8 +182,8 @@ void interceptAjaxRequest() { skippableTestWidgets('send URLSearchParams data', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer shouldInterceptAjaxPostRequestCompleter = Completer(); final Completer> onAjaxReadyStateChangeCompleter = @@ -266,8 +266,8 @@ void interceptAjaxRequest() { }); skippableTestWidgets('send FormData', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer shouldInterceptAjaxPostRequestCompleter = Completer(); final Completer> onAjaxReadyStateChangeCompleter = diff --git a/example/integration_test/in_app_webview/intercept_fetch_request.dart b/example/integration_test/in_app_webview/intercept_fetch_request.dart index 0b42d64d..982dee13 100644 --- a/example/integration_test/in_app_webview/intercept_fetch_request.dart +++ b/example/integration_test/in_app_webview/intercept_fetch_request.dart @@ -11,8 +11,8 @@ void interceptFetchRequest() { skippableGroup('intercept fetch request', () { skippableTestWidgets('send string data', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer> fetchPostCompleter = Completer>(); final Completer shouldInterceptFetchPostRequestCompleter = @@ -86,8 +86,8 @@ void interceptFetchRequest() { }); skippableTestWidgets('send json data', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer> fetchPostCompleter = Completer>(); final Completer shouldInterceptFetchPostRequestCompleter = @@ -168,8 +168,8 @@ void interceptFetchRequest() { skippableTestWidgets('send URLSearchParams data', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer> fetchPostCompleter = Completer>(); final Completer shouldInterceptFetchPostRequestCompleter = @@ -245,8 +245,8 @@ void interceptFetchRequest() { }); skippableTestWidgets('send FormData', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer> fetchPostCompleter = Completer>(); final Completer shouldInterceptFetchPostRequestCompleter = diff --git a/example/integration_test/in_app_webview/is_loading.dart b/example/integration_test/in_app_webview/is_loading.dart index 7b76704e..3323e7fc 100644 --- a/example/integration_test/in_app_webview/is_loading.dart +++ b/example/integration_test/in_app_webview/is_loading.dart @@ -10,8 +10,8 @@ void isLoading() { ].contains(defaultTargetPlatform); skippableTestWidgets('isLoading', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageStarted = Completer(); final Completer pageLoaded = Completer(); @@ -35,7 +35,7 @@ void isLoading() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageStarted.future; expect(await controller.isLoading(), true); diff --git a/example/integration_test/in_app_webview/is_secure_context.dart b/example/integration_test/in_app_webview/is_secure_context.dart index 81c0e4b6..3c5d8a6c 100644 --- a/example/integration_test/in_app_webview/is_secure_context.dart +++ b/example/integration_test/in_app_webview/is_secure_context.dart @@ -12,8 +12,8 @@ void isSecureContext() { var url = !kIsWeb ? TEST_CROSS_PLATFORM_URL_1 : TEST_WEB_PLATFORM_URL_1; skippableTestWidgets('isSecureContext', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final StreamController pageLoads = StreamController.broadcast(); @@ -33,7 +33,7 @@ void isSecureContext() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoads.stream.first; expect(await controller.isSecureContext(), true); diff --git a/example/integration_test/in_app_webview/javascript_code_evaluation.dart b/example/integration_test/in_app_webview/javascript_code_evaluation.dart index bdff96ea..8f9a683f 100644 --- a/example/integration_test/in_app_webview/javascript_code_evaluation.dart +++ b/example/integration_test/in_app_webview/javascript_code_evaluation.dart @@ -19,8 +19,8 @@ void javascriptCodeEvaluation() { ].contains(defaultTargetPlatform); skippableTestWidgets('evaluateJavascript', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -38,7 +38,7 @@ void javascriptCodeEvaluation() { ), ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; @@ -63,8 +63,8 @@ void javascriptCodeEvaluation() { skippableTestWidgets('evaluateJavascript with content world', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -82,7 +82,7 @@ void javascriptCodeEvaluation() { ), ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; @@ -107,8 +107,8 @@ void javascriptCodeEvaluation() { ].contains(defaultTargetPlatform); skippableTestWidgets('callAsyncJavaScript', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -126,7 +126,7 @@ void javascriptCodeEvaluation() { ), ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; @@ -169,8 +169,8 @@ void javascriptCodeEvaluation() { skippableTestWidgets('callAsyncJavaScript with content world', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -188,7 +188,7 @@ void javascriptCodeEvaluation() { ), ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; diff --git a/example/integration_test/in_app_webview/javascript_dialogs.dart b/example/integration_test/in_app_webview/javascript_dialogs.dart index 3f0c804a..6b465425 100644 --- a/example/integration_test/in_app_webview/javascript_dialogs.dart +++ b/example/integration_test/in_app_webview/javascript_dialogs.dart @@ -10,8 +10,8 @@ void javascriptDialogs() { ].contains(defaultTargetPlatform); skippableTestWidgets('javascript dialogs', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); final Completer alertCompleter = Completer(); diff --git a/example/integration_test/in_app_webview/javascript_handler.dart b/example/integration_test/in_app_webview/javascript_handler.dart index fee6064f..5658ca62 100644 --- a/example/integration_test/in_app_webview/javascript_handler.dart +++ b/example/integration_test/in_app_webview/javascript_handler.dart @@ -10,8 +10,8 @@ void javascriptHandler() { ].contains(defaultTargetPlatform); skippableTestWidgets('JavaScript Handler', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageStarted = Completer(); final Completer pageLoaded = Completer(); final Completer handlerFoo = Completer(); diff --git a/example/integration_test/in_app_webview/keep_alive.dart b/example/integration_test/in_app_webview/keep_alive.dart index 93e9ead4..dac09ac3 100644 --- a/example/integration_test/in_app_webview/keep_alive.dart +++ b/example/integration_test/in_app_webview/keep_alive.dart @@ -15,10 +15,10 @@ void keepAlive() { skippableTestWidgets('Keep Alive', (WidgetTester tester) async { final keepAlive = InAppWebViewKeepAlive(); - final Completer controllerCompleter = - Completer(); - final Completer controllerCompleter2 = - Completer(); + final Completer controllerCompleter = + Completer(); + final Completer controllerCompleter2 = + Completer(); final Completer pageLoaded = Completer(); final Completer pageLoaded2 = Completer(); @@ -46,7 +46,7 @@ void keepAlive() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await controller.loadUrl( @@ -64,7 +64,7 @@ void keepAlive() { }, )), ); - final PlatformInAppWebViewController controller2 = + final InAppWebViewController controller2 = await controllerCompleter2.future; final String? currentUrl = (await controller2.getUrl())?.toString(); diff --git a/example/integration_test/in_app_webview/load_data.dart b/example/integration_test/in_app_webview/load_data.dart index 7501b858..e5fb32ee 100644 --- a/example/integration_test/in_app_webview/load_data.dart +++ b/example/integration_test/in_app_webview/load_data.dart @@ -10,8 +10,8 @@ void loadData() { ].contains(defaultTargetPlatform); skippableTestWidgets('loadData', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final StreamController pageLoads = StreamController.broadcast(); @@ -31,7 +31,7 @@ void loadData() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoads.stream.first; final data = """ diff --git a/example/integration_test/in_app_webview/load_file.dart b/example/integration_test/in_app_webview/load_file.dart index 225489a4..09dbbcc8 100644 --- a/example/integration_test/in_app_webview/load_file.dart +++ b/example/integration_test/in_app_webview/load_file.dart @@ -10,8 +10,8 @@ void loadFile() { ].contains(defaultTargetPlatform); skippableTestWidgets('loadFile', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final StreamController pageLoads = StreamController.broadcast(); @@ -31,7 +31,7 @@ void loadFile() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoads.stream.first; await controller.loadFile( diff --git a/example/integration_test/in_app_webview/load_url.dart b/example/integration_test/in_app_webview/load_url.dart index dfa7657c..bdb1f5be 100644 --- a/example/integration_test/in_app_webview/load_url.dart +++ b/example/integration_test/in_app_webview/load_url.dart @@ -12,8 +12,8 @@ void loadUrl() { var initialUrl = !kIsWeb ? TEST_URL_1 : TEST_WEB_PLATFORM_URL_1; skippableTestWidgets('loadUrl', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer firstUrlLoad = Completer(); final Completer loadedUrl = Completer(); @@ -38,7 +38,7 @@ void loadUrl() { ), ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; expect(await firstUrlLoad.future, initialUrl.toString()); await controller.loadUrl( @@ -54,8 +54,8 @@ void loadUrl() { ].contains(defaultTargetPlatform); skippableTestWidgets('loadSimulatedRequest', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer firstUrlLoad = Completer(); final Completer loadedUrl = Completer(); @@ -80,7 +80,7 @@ void loadUrl() { ), ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; expect(await firstUrlLoad.future, initialUrl.toString()); final htmlCode = "

Hello

"; diff --git a/example/integration_test/in_app_webview/on_console_message.dart b/example/integration_test/in_app_webview/on_console_message.dart index 72c682d1..495d12c4 100644 --- a/example/integration_test/in_app_webview/on_console_message.dart +++ b/example/integration_test/in_app_webview/on_console_message.dart @@ -10,8 +10,8 @@ void onConsoleMessage() { ].contains(defaultTargetPlatform); skippableTestWidgets('onConsoleMessage', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer onConsoleMessageCompleter = Completer(); await tester.pumpWidget( diff --git a/example/integration_test/in_app_webview/on_download_start_request.dart b/example/integration_test/in_app_webview/on_download_start_request.dart index 6c7099e2..ba735534 100644 --- a/example/integration_test/in_app_webview/on_download_start_request.dart +++ b/example/integration_test/in_app_webview/on_download_start_request.dart @@ -10,8 +10,8 @@ void onDownloadStartRequest() { ].contains(defaultTargetPlatform); skippableTestWidgets('onDownloadStartRequest', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer onDownloadStartCompleter = Completer(); await tester.pumpWidget( Directionality( diff --git a/example/integration_test/in_app_webview/on_js_before_unload.dart b/example/integration_test/in_app_webview/on_js_before_unload.dart index 887d26b2..19471c59 100644 --- a/example/integration_test/in_app_webview/on_js_before_unload.dart +++ b/example/integration_test/in_app_webview/on_js_before_unload.dart @@ -9,8 +9,8 @@ void onJsBeforeUnload() { final shouldSkip = true; // on Android, for some reason, it works on an example app but not in this test skippableTestWidgets('onJsBeforeUnload', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer onJsBeforeUnloadCompleter = Completer(); await tester.pumpWidget( diff --git a/example/integration_test/in_app_webview/on_load_resource_with_custom_scheme.dart b/example/integration_test/in_app_webview/on_load_resource_with_custom_scheme.dart index 31e82c8a..4b0964f1 100644 --- a/example/integration_test/in_app_webview/on_load_resource_with_custom_scheme.dart +++ b/example/integration_test/in_app_webview/on_load_resource_with_custom_scheme.dart @@ -11,8 +11,8 @@ void onLoadResourceWithCustomScheme() { skippableTestWidgets('onLoadResourceWithCustomScheme', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer imageLoaded = Completer(); await tester.pumpWidget( diff --git a/example/integration_test/in_app_webview/on_navigation_response.dart b/example/integration_test/in_app_webview/on_navigation_response.dart index 83ad74b0..70aea1d9 100644 --- a/example/integration_test/in_app_webview/on_navigation_response.dart +++ b/example/integration_test/in_app_webview/on_navigation_response.dart @@ -10,8 +10,8 @@ void onNavigationResponse() { skippableGroup('onNavigationResponse', () { skippableTestWidgets('allow navigation', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); final Completer onNavigationResponseCompleter = Completer(); @@ -43,8 +43,8 @@ void onNavigationResponse() { }); skippableTestWidgets('cancel navigation', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); final Completer onNavigationResponseCompleter = Completer(); diff --git a/example/integration_test/in_app_webview/on_page_commit_visible.dart b/example/integration_test/in_app_webview/on_page_commit_visible.dart index cd4c3ebb..ecfd036d 100644 --- a/example/integration_test/in_app_webview/on_page_commit_visible.dart +++ b/example/integration_test/in_app_webview/on_page_commit_visible.dart @@ -10,8 +10,8 @@ void onPageCommitVisible() { ].contains(defaultTargetPlatform); skippableTestWidgets('onPageCommitVisible', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer onPageCommitVisibleCompleter = Completer(); await tester.pumpWidget( diff --git a/example/integration_test/in_app_webview/on_permission_request.dart b/example/integration_test/in_app_webview/on_permission_request.dart index 99c7fbd2..115adb27 100644 --- a/example/integration_test/in_app_webview/on_permission_request.dart +++ b/example/integration_test/in_app_webview/on_permission_request.dart @@ -12,8 +12,8 @@ void onPermissionRequest() { final expectedValue = [PermissionResourceType.CAMERA]; skippableTestWidgets('onPermissionRequest', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); final Completer> onPermissionRequestCompleter = Completer>(); @@ -40,7 +40,7 @@ void onPermissionRequest() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await controller.evaluateJavascript( source: "document.querySelector('#camera').click();"); @@ -61,8 +61,8 @@ void onPermissionRequest() { skippableTestWidgets('onPermissionRequestCanceled', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); final Completer> onPermissionRequestCompleter = Completer>(); @@ -99,7 +99,7 @@ void onPermissionRequest() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await controller.evaluateJavascript( source: "document.querySelector('#camera').click();"); diff --git a/example/integration_test/in_app_webview/on_received_icon.dart b/example/integration_test/in_app_webview/on_received_icon.dart index a8d7aedb..22d6c5c1 100644 --- a/example/integration_test/in_app_webview/on_received_icon.dart +++ b/example/integration_test/in_app_webview/on_received_icon.dart @@ -8,8 +8,8 @@ void onReceivedIcon() { ].contains(defaultTargetPlatform); skippableTestWidgets('onReceivedIcon', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); final Completer onReceivedIconCompleter = Completer(); diff --git a/example/integration_test/in_app_webview/on_received_touch_icon_url.dart b/example/integration_test/in_app_webview/on_received_touch_icon_url.dart index 63a6dc9a..3f3e9ad9 100644 --- a/example/integration_test/in_app_webview/on_received_touch_icon_url.dart +++ b/example/integration_test/in_app_webview/on_received_touch_icon_url.dart @@ -8,8 +8,8 @@ void onReceivedTouchIconUrl() { ].contains(defaultTargetPlatform); skippableTestWidgets('onReceivedTouchIconUrl', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer onReceivedTouchIconUrlCompleter = Completer(); diff --git a/example/integration_test/in_app_webview/on_scroll_changed.dart b/example/integration_test/in_app_webview/on_scroll_changed.dart index b2d0da80..6903cbc8 100644 --- a/example/integration_test/in_app_webview/on_scroll_changed.dart +++ b/example/integration_test/in_app_webview/on_scroll_changed.dart @@ -12,8 +12,8 @@ void onScrollChanged() { var url = !kIsWeb ? TEST_URL_1 : TEST_WEB_PLATFORM_URL_1; skippableTestWidgets('onScrollChanged', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); final Completer onScrollChangedCompleter = Completer(); await tester.pumpWidget( @@ -37,7 +37,7 @@ void onScrollChanged() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await tester.pump(); diff --git a/example/integration_test/in_app_webview/on_title_changed.dart b/example/integration_test/in_app_webview/on_title_changed.dart index 25b3c740..d0f6fb5a 100644 --- a/example/integration_test/in_app_webview/on_title_changed.dart +++ b/example/integration_test/in_app_webview/on_title_changed.dart @@ -12,8 +12,8 @@ void onTitleChanged() { var url = !kIsWeb ? TEST_URL_1 : TEST_WEB_PLATFORM_URL_1; skippableTestWidgets('onTitleChanged', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); final Completer onTitleChangedCompleter = Completer(); @@ -40,7 +40,7 @@ void onTitleChanged() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await tester.pump(); await controller.evaluateJavascript( diff --git a/example/integration_test/in_app_webview/on_update_visited_history.dart b/example/integration_test/in_app_webview/on_update_visited_history.dart index c6655b57..9976e81e 100644 --- a/example/integration_test/in_app_webview/on_update_visited_history.dart +++ b/example/integration_test/in_app_webview/on_update_visited_history.dart @@ -12,8 +12,8 @@ void onUpdateVisitedHistory() { var url = !kIsWeb ? TEST_CROSS_PLATFORM_URL_1 : TEST_WEB_PLATFORM_URL_1; skippableTestWidgets('onUpdateVisitedHistory', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer firstPushCompleter = Completer(); final Completer secondPushCompleter = Completer(); final Completer pageLoaded = Completer(); @@ -42,7 +42,7 @@ void onUpdateVisitedHistory() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await controller.evaluateJavascript(source: """ diff --git a/example/integration_test/in_app_webview/page_down_up.dart b/example/integration_test/in_app_webview/page_down_up.dart index ee12d261..ccc8e1d1 100644 --- a/example/integration_test/in_app_webview/page_down_up.dart +++ b/example/integration_test/in_app_webview/page_down_up.dart @@ -8,8 +8,8 @@ void pageDownUp() { ].contains(defaultTargetPlatform); skippableTestWidgets('pageDown/pageUp', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -28,7 +28,7 @@ void pageDownUp() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await tester.pump(); await Future.delayed(Duration(seconds: 1)); diff --git a/example/integration_test/in_app_webview/pause_resume.dart b/example/integration_test/in_app_webview/pause_resume.dart index 3d68afe8..9c4c80f2 100644 --- a/example/integration_test/in_app_webview/pause_resume.dart +++ b/example/integration_test/in_app_webview/pause_resume.dart @@ -8,8 +8,8 @@ void pauseResume() { ].contains(defaultTargetPlatform); skippableTestWidgets('pause/resume', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -28,7 +28,7 @@ void pauseResume() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await expectLater(controller.pause(), completes); await Future.delayed(Duration(seconds: 1)); diff --git a/example/integration_test/in_app_webview/pause_resume_timers.dart b/example/integration_test/in_app_webview/pause_resume_timers.dart index 7255681b..e00fa6f9 100644 --- a/example/integration_test/in_app_webview/pause_resume_timers.dart +++ b/example/integration_test/in_app_webview/pause_resume_timers.dart @@ -10,8 +10,8 @@ void pauseResumeTimers() { ].contains(defaultTargetPlatform); skippableTestWidgets('pause/resume timers', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -30,7 +30,7 @@ void pauseResumeTimers() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await controller.evaluateJavascript(source: """ diff --git a/example/integration_test/in_app_webview/post_requests.dart b/example/integration_test/in_app_webview/post_requests.dart index feae01eb..d771e533 100644 --- a/example/integration_test/in_app_webview/post_requests.dart +++ b/example/integration_test/in_app_webview/post_requests.dart @@ -11,8 +11,8 @@ void postRequests() { skippableGroup('POST requests', () { skippableTestWidgets('initialUrlRequest', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer postPageLoaded = Completer(); await tester.pumpWidget( @@ -36,7 +36,7 @@ void postRequests() { ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await postPageLoaded.future; @@ -50,8 +50,8 @@ void postRequests() { }); skippableTestWidgets('loadUrl', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer postPageLoaded = Completer(); await tester.pumpWidget( @@ -72,7 +72,7 @@ void postRequests() { ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; var postData = Uint8List.fromList(utf8.encode("name=FooBar")); @@ -96,8 +96,8 @@ void postRequests() { }); skippableTestWidgets('postUrl', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer postPageLoaded = Completer(); await tester.pumpWidget( @@ -118,7 +118,7 @@ void postRequests() { ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; var postData = Uint8List.fromList(utf8.encode("name=FooBar")); diff --git a/example/integration_test/in_app_webview/print_current_page.dart b/example/integration_test/in_app_webview/print_current_page.dart index 1ff639d4..13a11c0f 100644 --- a/example/integration_test/in_app_webview/print_current_page.dart +++ b/example/integration_test/in_app_webview/print_current_page.dart @@ -12,8 +12,8 @@ void printCurrentPage() { var url = !kIsWeb ? TEST_CROSS_PLATFORM_URL_1 : TEST_WEB_PLATFORM_URL_1; skippableTestWidgets('printCurrentPage', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -32,7 +32,7 @@ void printCurrentPage() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await tester.pump(); await expectLater(controller.printCurrentPage(), completes); diff --git a/example/integration_test/in_app_webview/programmatic_scroll.dart b/example/integration_test/in_app_webview/programmatic_scroll.dart index aaf451b2..640e7129 100644 --- a/example/integration_test/in_app_webview/programmatic_scroll.dart +++ b/example/integration_test/in_app_webview/programmatic_scroll.dart @@ -49,8 +49,8 @@ void programmaticScroll() { : TEST_WEB_PLATFORM_URL_1; final Completer pageLoaded = Completer(); - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); await tester.pumpWidget( Directionality( @@ -67,7 +67,7 @@ void programmaticScroll() { ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; @@ -127,8 +127,8 @@ void programmaticScroll() { base64Encode(const Utf8Encoder().convert(scrollTestPage)); final Completer pageLoaded = Completer(); - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); await tester.pumpWidget( Directionality( @@ -148,7 +148,7 @@ void programmaticScroll() { ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await controller.scrollTo(x: 0, y: 0); diff --git a/example/integration_test/in_app_webview/programmatic_zoom_scale.dart b/example/integration_test/in_app_webview/programmatic_zoom_scale.dart index e589ecd2..5694f5c0 100644 --- a/example/integration_test/in_app_webview/programmatic_zoom_scale.dart +++ b/example/integration_test/in_app_webview/programmatic_zoom_scale.dart @@ -17,8 +17,8 @@ void programmaticZoomScale() { ].contains(defaultTargetPlatform); skippableTestWidgets('zoomIn/zoomOut', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -37,7 +37,7 @@ void programmaticZoomScale() { ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; expect(await controller.zoomIn(), true); @@ -46,8 +46,8 @@ void programmaticZoomScale() { }, skip: shouldSkipTest1); skippableTestWidgets('onZoomScaleChanged', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); final Completer onZoomScaleChangedCompleter = Completer(); @@ -76,7 +76,7 @@ void programmaticZoomScale() { ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; listenForScaleChange = true; @@ -87,8 +87,8 @@ void programmaticZoomScale() { }); skippableTestWidgets('zoomBy', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -107,7 +107,7 @@ void programmaticZoomScale() { ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; @@ -116,8 +116,8 @@ void programmaticZoomScale() { }); skippableTestWidgets('getZoomScale', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -136,7 +136,7 @@ void programmaticZoomScale() { ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; diff --git a/example/integration_test/in_app_webview/pull_to_refresh.dart b/example/integration_test/in_app_webview/pull_to_refresh.dart index a69a1193..8ab88ae7 100644 --- a/example/integration_test/in_app_webview/pull_to_refresh.dart +++ b/example/integration_test/in_app_webview/pull_to_refresh.dart @@ -11,8 +11,8 @@ void pullToRefresh() { skippableTestWidgets('launches with pull-to-refresh feature', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final pullToRefreshController = PullToRefreshController( settings: PullToRefreshSettings( color: Colors.blue, @@ -38,7 +38,7 @@ void pullToRefresh() { ), ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; final String? currentUrl = (await controller.getUrl())?.toString(); expect(currentUrl, TEST_URL_1.toString()); }, skip: shouldSkip); diff --git a/example/integration_test/in_app_webview/reload.dart b/example/integration_test/in_app_webview/reload.dart index 3ca577be..5cdb218d 100644 --- a/example/integration_test/in_app_webview/reload.dart +++ b/example/integration_test/in_app_webview/reload.dart @@ -20,8 +20,8 @@ void reload() { ].contains(defaultTargetPlatform); skippableTestWidgets('from origin', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -42,15 +42,15 @@ void reload() { ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await expectLater(controller.reloadFromOrigin(), completes); }, skip: shouldSkipTest1); skippableTestWidgets('basic', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final StreamController pageLoads = StreamController.broadcast(); @@ -69,7 +69,7 @@ void reload() { ), ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; String? reloadUrl = await pageLoads.stream.first; expect(reloadUrl, url.toString()); diff --git a/example/integration_test/in_app_webview/request_focus_node_href.dart b/example/integration_test/in_app_webview/request_focus_node_href.dart index 94b786c6..36c122fc 100644 --- a/example/integration_test/in_app_webview/request_focus_node_href.dart +++ b/example/integration_test/in_app_webview/request_focus_node_href.dart @@ -10,8 +10,8 @@ void requestFocusNodeHref() { ].contains(defaultTargetPlatform); skippableTestWidgets('requestFocusNodeHref', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -30,7 +30,7 @@ void requestFocusNodeHref() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await expectLater(controller.requestFocusNodeHref(), completes); diff --git a/example/integration_test/in_app_webview/request_image_ref.dart b/example/integration_test/in_app_webview/request_image_ref.dart index 626308cc..dbefee32 100644 --- a/example/integration_test/in_app_webview/request_image_ref.dart +++ b/example/integration_test/in_app_webview/request_image_ref.dart @@ -10,8 +10,8 @@ void requestImageRef() { ].contains(defaultTargetPlatform); skippableTestWidgets('requestImageRef', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -30,7 +30,7 @@ void requestImageRef() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await expectLater(controller.requestImageRef(), completes); diff --git a/example/integration_test/in_app_webview/resize_webview.dart b/example/integration_test/in_app_webview/resize_webview.dart index 8e052a74..43540d09 100644 --- a/example/integration_test/in_app_webview/resize_webview.dart +++ b/example/integration_test/in_app_webview/resize_webview.dart @@ -31,8 +31,8 @@ void resizeWebView() { final Completer resizeCompleter = Completer(); final Completer pageStarted = Completer(); final Completer pageLoaded = Completer(); - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final GlobalKey key = GlobalKey(); final InAppWebView webView = InAppWebView( diff --git a/example/integration_test/in_app_webview/set_custom_useragent.dart b/example/integration_test/in_app_webview/set_custom_useragent.dart index c4e558cc..56c7dc61 100644 --- a/example/integration_test/in_app_webview/set_custom_useragent.dart +++ b/example/integration_test/in_app_webview/set_custom_useragent.dart @@ -10,7 +10,7 @@ void setCustomUserAgent() { ].contains(defaultTargetPlatform); skippableTestWidgets('set custom userAgent', (WidgetTester tester) async { - final Completer controllerCompleter1 = Completer(); + final Completer controllerCompleter1 = Completer(); await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, diff --git a/example/integration_test/in_app_webview/set_get_settings.dart b/example/integration_test/in_app_webview/set_get_settings.dart index 28e2cd15..2c5a6d0f 100644 --- a/example/integration_test/in_app_webview/set_get_settings.dart +++ b/example/integration_test/in_app_webview/set_get_settings.dart @@ -12,8 +12,8 @@ void setGetSettings() { final url = !kIsWeb ? TEST_CROSS_PLATFORM_URL_1 : TEST_WEB_PLATFORM_URL_1; skippableTestWidgets('set/get settings', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -32,7 +32,7 @@ void setGetSettings() { ), ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; InAppWebViewSettings? settings = await controller.getSettings(); diff --git a/example/integration_test/in_app_webview/should_intercept_request.dart b/example/integration_test/in_app_webview/should_intercept_request.dart index bfb44c54..c3fd7baf 100644 --- a/example/integration_test/in_app_webview/should_intercept_request.dart +++ b/example/integration_test/in_app_webview/should_intercept_request.dart @@ -15,8 +15,8 @@ void shouldInterceptRequest() { ]; List resourceLoaded = []; - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); final Completer loadedResourceCompleter = Completer(); diff --git a/example/integration_test/in_app_webview/should_override_url_loading.dart b/example/integration_test/in_app_webview/should_override_url_loading.dart index 4a270410..507331e9 100644 --- a/example/integration_test/in_app_webview/should_override_url_loading.dart +++ b/example/integration_test/in_app_webview/should_override_url_loading.dart @@ -16,8 +16,8 @@ void shouldOverrideUrlLoading() { base64Encode(const Utf8Encoder().convert(page)); skippableTestWidgets('can allow requests', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final StreamController pageLoads = StreamController.broadcast(); await tester.pumpWidget( @@ -43,7 +43,7 @@ void shouldOverrideUrlLoading() { ); await pageLoads.stream.first; // Wait for initial page load. - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await controller.evaluateJavascript( source: 'location.href = "$TEST_URL_2"'); @@ -65,8 +65,8 @@ void shouldOverrideUrlLoading() { testWidgets( 'allow requests on iOS only if navigationType == NavigationType.LINK_ACTIVATED', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final StreamController pageLoads = StreamController.broadcast(); await tester.pumpWidget( @@ -94,7 +94,7 @@ void shouldOverrideUrlLoading() { ); await pageLoads.stream.first; // Wait for initial page load. - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await controller.evaluateJavascript( source: 'location.href = "$TEST_URL_2"'); @@ -120,8 +120,8 @@ void shouldOverrideUrlLoading() { }, skip: shouldSkipTest2); skippableTestWidgets('can block requests', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final StreamController pageLoads = StreamController.broadcast(); await tester.pumpWidget( @@ -147,7 +147,7 @@ void shouldOverrideUrlLoading() { ); await pageLoads.stream.first; // Wait for initial page load. - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await controller.evaluateJavascript( source: 'location.href = "$TEST_URL_4"'); @@ -169,8 +169,8 @@ void shouldOverrideUrlLoading() { skippableTestWidgets('supports asynchronous decisions', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final StreamController pageLoads = StreamController.broadcast(); await tester.pumpWidget( @@ -197,7 +197,7 @@ void shouldOverrideUrlLoading() { ); await pageLoads.stream.first; // Wait for initial page load. - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await controller.evaluateJavascript( source: 'location.href = "$TEST_URL_2"'); diff --git a/example/integration_test/in_app_webview/ssl_request.dart b/example/integration_test/in_app_webview/ssl_request.dart index 27d0a1f7..094c1f20 100644 --- a/example/integration_test/in_app_webview/ssl_request.dart +++ b/example/integration_test/in_app_webview/ssl_request.dart @@ -10,8 +10,8 @@ void sslRequest() { ].contains(defaultTargetPlatform); skippableTestWidgets('SSL request', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( Directionality( @@ -40,7 +40,7 @@ void sslRequest() { ), ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; final String h1Content = await controller.evaluateJavascript( diff --git a/example/integration_test/in_app_webview/stop_loading.dart b/example/integration_test/in_app_webview/stop_loading.dart index eb542bca..a4c2c0d7 100644 --- a/example/integration_test/in_app_webview/stop_loading.dart +++ b/example/integration_test/in_app_webview/stop_loading.dart @@ -10,8 +10,8 @@ void stopLoading() { ].contains(defaultTargetPlatform); skippableTestWidgets('stopLoading', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -34,7 +34,7 @@ void stopLoading() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; if (defaultTargetPlatform == TargetPlatform.android) { await pageLoaded.future; diff --git a/example/integration_test/in_app_webview/t_rex_runner_game.dart b/example/integration_test/in_app_webview/t_rex_runner_game.dart index 5dcdc237..b1f98295 100644 --- a/example/integration_test/in_app_webview/t_rex_runner_game.dart +++ b/example/integration_test/in_app_webview/t_rex_runner_game.dart @@ -10,8 +10,8 @@ void tRexRunnerGame() { ].contains(defaultTargetPlatform); skippableTestWidgets('T-Rex Runner game', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( diff --git a/example/integration_test/in_app_webview/take_screenshot.dart b/example/integration_test/in_app_webview/take_screenshot.dart index d6d532d8..49a126a1 100644 --- a/example/integration_test/in_app_webview/take_screenshot.dart +++ b/example/integration_test/in_app_webview/take_screenshot.dart @@ -10,8 +10,8 @@ void takeScreenshot() { ].contains(defaultTargetPlatform); skippableTestWidgets('takeScreenshot', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -30,7 +30,7 @@ void takeScreenshot() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await Future.delayed(Duration(seconds: 1)); diff --git a/example/integration_test/in_app_webview/user_scripts.dart b/example/integration_test/in_app_webview/user_scripts.dart index a09ea97e..078218ca 100644 --- a/example/integration_test/in_app_webview/user_scripts.dart +++ b/example/integration_test/in_app_webview/user_scripts.dart @@ -11,8 +11,8 @@ void userScripts() { skippableGroup('user scripts', () { skippableTestWidgets('initialUserScripts', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -47,7 +47,7 @@ void userScripts() { ), ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; @@ -71,8 +71,8 @@ void userScripts() { skippableTestWidgets('add/remove user scripts', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final StreamController pageLoads = StreamController.broadcast(); @@ -92,7 +92,7 @@ void userScripts() { ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await pageLoads.stream.first; diff --git a/example/integration_test/in_app_webview/video_playback_policy.dart b/example/integration_test/in_app_webview/video_playback_policy.dart index 6c56ad10..6188967c 100644 --- a/example/integration_test/in_app_webview/video_playback_policy.dart +++ b/example/integration_test/in_app_webview/video_playback_policy.dart @@ -50,8 +50,8 @@ void videoPlaybackPolicy() { }); skippableTestWidgets('Auto media playback', (WidgetTester tester) async { - Completer controllerCompleter = - Completer(); + Completer controllerCompleter = + Completer(); Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -74,14 +74,14 @@ void videoPlaybackPolicy() { ), ), ); - PlatformInAppWebViewController controller = await controllerCompleter.future; + InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; bool isPaused = await controller.evaluateJavascript(source: 'isPaused();'); expect(isPaused, false); - controllerCompleter = Completer(); + controllerCompleter = Completer(); pageLoaded = Completer(); // We change the key to re-create a new webview as we change the mediaPlaybackRequiresUserGesture @@ -123,8 +123,8 @@ void videoPlaybackPolicy() { skippableTestWidgets( 'Video plays inline when allowsInlineMediaPlayback is true', (WidgetTester tester) async { - Completer controllerCompleter = - Completer(); + Completer controllerCompleter = + Completer(); Completer pageLoaded = Completer(); Completer onEnterFullscreenCompleter = Completer(); @@ -167,8 +167,8 @@ void videoPlaybackPolicy() { testWidgets( 'Video plays fullscreen when allowsInlineMediaPlayback is false', (WidgetTester tester) async { - Completer controllerCompleter = - Completer(); + Completer controllerCompleter = + Completer(); Completer pageLoaded = Completer(); Completer onEnterFullscreenCompleter = Completer(); @@ -212,8 +212,8 @@ void videoPlaybackPolicy() { ].contains(defaultTargetPlatform); // on Android, entering fullscreen requires user interaction skippableTestWidgets('exit fullscreen event', (WidgetTester tester) async { - Completer controllerCompleter = - Completer(); + Completer controllerCompleter = + Completer(); Completer pageLoaded = Completer(); Completer onExitFullscreenCompleter = Completer(); @@ -242,7 +242,7 @@ void videoPlaybackPolicy() { ), ); - PlatformInAppWebViewController controller = await controllerCompleter.future; + InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; await Future.delayed(Duration(seconds: 2)); diff --git a/example/integration_test/in_app_webview/web_archive.dart b/example/integration_test/in_app_webview/web_archive.dart index af237bc4..914011ec 100644 --- a/example/integration_test/in_app_webview/web_archive.dart +++ b/example/integration_test/in_app_webview/web_archive.dart @@ -18,8 +18,8 @@ void webArchive() { ].contains(defaultTargetPlatform); skippableTestWidgets('create data', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -38,7 +38,7 @@ void webArchive() { ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; @@ -46,8 +46,8 @@ void webArchive() { }, skip: shouldSkipTest1); skippableTestWidgets('save', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -66,7 +66,7 @@ void webArchive() { ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await pageLoaded.future; diff --git a/example/integration_test/in_app_webview/web_history.dart b/example/integration_test/in_app_webview/web_history.dart index 10660a41..bfe9d7c9 100644 --- a/example/integration_test/in_app_webview/web_history.dart +++ b/example/integration_test/in_app_webview/web_history.dart @@ -20,8 +20,8 @@ void webHistory() { skippableTestWidgets('get history list and go back/forward', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); await tester.pumpWidget( Directionality( @@ -39,7 +39,7 @@ void webHistory() { ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await Future.delayed(Duration(seconds: 1)); @@ -119,8 +119,8 @@ void webHistory() { skippableTestWidgets('go back/forward on web platform', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final StreamController pageLoads = StreamController.broadcast(); @@ -140,7 +140,7 @@ void webHistory() { ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await tester.pump(); @@ -178,8 +178,8 @@ void webHistory() { ].contains(defaultTargetPlatform); skippableTestWidgets('clearHistory', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final StreamController pageLoads = StreamController.broadcast(); @@ -199,7 +199,7 @@ void webHistory() { ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await pageLoads.stream.first; await controller.loadUrl(urlRequest: URLRequest(url: TEST_URL_1)); diff --git a/example/integration_test/in_app_webview/web_message.dart b/example/integration_test/in_app_webview/web_message.dart index fec8697c..2deafb9f 100644 --- a/example/integration_test/in_app_webview/web_message.dart +++ b/example/integration_test/in_app_webview/web_message.dart @@ -12,8 +12,8 @@ void webMessage() { skippableGroup('WebMessage', () { skippableTestWidgets('WebMessageChannel post String', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer webMessageCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -81,8 +81,8 @@ void webMessage() { skippableTestWidgets('WebMessageChannel post ArrayBuffer', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer webMessageCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -167,8 +167,8 @@ void webMessage() { skippableTestWidgets('WebMessageListener post String', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); final Completer webMessageCompleter = Completer(); await tester.pumpWidget( @@ -177,7 +177,7 @@ void webMessage() { child: InAppWebView( key: GlobalKey(), onWebViewCreated: (controller) async { - await InAppWebViewController.fromPlatform(platform: controller).addWebMessageListener(WebMessageListener( + await controller.addWebMessageListener(WebMessageListener( jsObjectName: "myTestObj", allowedOriginRules: Set.from(["https://*.example.com"]), onPostMessage: @@ -222,8 +222,8 @@ void webMessage() { skippableTestWidgets('WebMessageListener post ArrayBuffer', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); final Completer webMessageCompleter = Completer(); await tester.pumpWidget( @@ -232,7 +232,7 @@ void webMessage() { child: InAppWebView( key: GlobalKey(), onWebViewCreated: (controller) async { - await InAppWebViewController.fromPlatform(platform: controller).addWebMessageListener(WebMessageListener( + await controller.addWebMessageListener(WebMessageListener( jsObjectName: "myTestObj", allowedOriginRules: Set.from(["https://*.example.com"]), onPostMessage: diff --git a/example/integration_test/in_app_webview/webview_asset_loader.dart b/example/integration_test/in_app_webview/webview_asset_loader.dart index a0f48427..97f959c2 100644 --- a/example/integration_test/in_app_webview/webview_asset_loader.dart +++ b/example/integration_test/in_app_webview/webview_asset_loader.dart @@ -8,8 +8,8 @@ void webViewAssetLoader() { ].contains(defaultTargetPlatform); skippableTestWidgets('WebViewAssetLoader', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( @@ -25,7 +25,7 @@ void webViewAssetLoader() { allowContentAccess: false, webViewAssetLoader: WebViewAssetLoader( domain: TEST_WEBVIEW_ASSET_LOADER_DOMAIN, - pathHandlers: [AssetsPathHandler(path: '/assets/')]).platform), + pathHandlers: [AssetsPathHandler(path: '/assets/')])), onWebViewCreated: (controller) { controllerCompleter.complete(controller); }, @@ -36,7 +36,7 @@ void webViewAssetLoader() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; final url = await pageLoaded.future; expect(url, TEST_WEBVIEW_ASSET_LOADER_URL.toString()); diff --git a/example/integration_test/in_app_webview/webview_windows.dart b/example/integration_test/in_app_webview/webview_windows.dart index 33011964..1db16a35 100644 --- a/example/integration_test/in_app_webview/webview_windows.dart +++ b/example/integration_test/in_app_webview/webview_windows.dart @@ -20,8 +20,8 @@ void webViewWindows() { skippableTestWidgets('onCreateWindow return false', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); await tester.pumpWidget( Directionality( @@ -63,8 +63,8 @@ void webViewWindows() { skippableTestWidgets('onCreateWindow return true', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer onCreateWindowCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -91,7 +91,7 @@ void webViewWindows() { var windowId = await onCreateWindowCompleter.future; final Completer windowControllerCompleter = - Completer(); + Completer(); final Completer windowPageLoaded = Completer(); final Completer onCloseWindowCompleter = Completer(); @@ -137,8 +137,8 @@ void webViewWindows() { skippableTestWidgets( 'window.open() with target _blank opens in same window', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final StreamController pageLoads = StreamController.broadcast(); await tester.pumpWidget( @@ -160,7 +160,7 @@ void webViewWindows() { ), ); await pageLoads.stream.first; - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await controller.evaluateJavascript( @@ -181,8 +181,8 @@ void webViewWindows() { // on Android, for some reason, it works on an example app but not in this test skippableTestWidgets('can open new window and go back', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final StreamController pageLoads = StreamController.broadcast(); await tester.pumpWidget( @@ -205,7 +205,7 @@ void webViewWindows() { ), ); await pageLoads.stream.first; - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await tester.pump(); @@ -264,8 +264,8 @@ void webViewWindows() { '''; final String openWindowTestBase64 = base64Encode(const Utf8Encoder().convert(openWindowTest)); - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoadCompleter = Completer(); await tester.pumpWidget( @@ -290,7 +290,7 @@ void webViewWindows() { ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await pageLoadCompleter.future; @@ -309,8 +309,8 @@ void webViewWindows() { // on Web, opening a new window during tests makes crash skippableTestWidgets('onCreateWindow called on Web', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer onCreateWindowCalled = Completer(); await tester.pumpWidget( Directionality( @@ -334,7 +334,7 @@ void webViewWindows() { ), ); - final PlatformInAppWebViewController controller = + final InAppWebViewController controller = await controllerCompleter.future; await controller.evaluateJavascript( source: "window.open('$TEST_CROSS_PLATFORM_URL_1');"); diff --git a/example/integration_test/proxy_controller/clear_and_set_proxy_override.dart b/example/integration_test/proxy_controller/clear_and_set_proxy_override.dart index 31b1a3fe..349902e6 100644 --- a/example/integration_test/proxy_controller/clear_and_set_proxy_override.dart +++ b/example/integration_test/proxy_controller/clear_and_set_proxy_override.dart @@ -9,8 +9,8 @@ void clearAndSetProxyOverride() { skippableTestWidgets('clear and set proxy override', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final Completer controllerCompleter = + Completer(); final Completer pageLoaded = Completer(); var proxyAvailable = @@ -42,7 +42,7 @@ void clearAndSetProxyOverride() { ), ); - final PlatformInAppWebViewController controller = await controllerCompleter.future; + final InAppWebViewController controller = await controllerCompleter.future; final String url = await pageLoaded.future; expect(url, TEST_URL_HTTP_EXAMPLE.toString()); diff --git a/example/integration_test/util.dart b/example/integration_test/util.dart index a6305352..031873ad 100644 --- a/example/integration_test/util.dart +++ b/example/integration_test/util.dart @@ -111,7 +111,7 @@ class MyInAppBrowser extends InAppBrowser { } } -class MyChromeSafariBrowser extends PlatformChromeSafariBrowser { +class MyChromeSafariBrowser extends ChromeSafariBrowser { final Completer serviceConnected = Completer(); final Completer opened = Completer(); final Completer firstPageLoaded = Completer(); diff --git a/example/integration_test/webview_flutter_test.dart b/example/integration_test/webview_flutter_test.dart index d69e7550..b6de238a 100644 --- a/example/integration_test/webview_flutter_test.dart +++ b/example/integration_test/webview_flutter_test.dart @@ -20,16 +20,16 @@ void main() { PlatformInAppWebViewController.debugLoggingSettings.usePrint = true; PlatformInAppWebViewController.debugLoggingSettings.maxLogMessageLength = 7000; - InAppBrowser.debugLoggingSettings.usePrint = true; - InAppBrowser.debugLoggingSettings.maxLogMessageLength = 7000; + PlatformInAppBrowser.debugLoggingSettings.usePrint = true; + PlatformInAppBrowser.debugLoggingSettings.maxLogMessageLength = 7000; PlatformChromeSafariBrowser.debugLoggingSettings.usePrint = true; PlatformChromeSafariBrowser.debugLoggingSettings.maxLogMessageLength = 7000; - WebAuthenticationSession.debugLoggingSettings.usePrint = true; - WebAuthenticationSession.debugLoggingSettings.maxLogMessageLength = 7000; - PullToRefreshController.debugLoggingSettings.usePrint = true; - PullToRefreshController.debugLoggingSettings.maxLogMessageLength = 7000; - FindInteractionController.debugLoggingSettings.usePrint = true; - FindInteractionController.debugLoggingSettings.maxLogMessageLength = 7000; + PlatformWebAuthenticationSession.debugLoggingSettings.usePrint = true; + PlatformWebAuthenticationSession.debugLoggingSettings.maxLogMessageLength = 7000; + PlatformPullToRefreshController.debugLoggingSettings.usePrint = true; + PlatformPullToRefreshController.debugLoggingSettings.maxLogMessageLength = 7000; + PlatformFindInteractionController.debugLoggingSettings.usePrint = true; + PlatformFindInteractionController.debugLoggingSettings.maxLogMessageLength = 7000; process_global_config_tests.main(); in_app_webview_tests.main(); diff --git a/example/lib/chrome_safari_browser_example.screen.dart b/example/lib/chrome_safari_browser_example.screen.dart index dfa8ca7c..99995909 100755 --- a/example/lib/chrome_safari_browser_example.screen.dart +++ b/example/lib/chrome_safari_browser_example.screen.dart @@ -4,7 +4,7 @@ import 'package:flutter_inappwebview/flutter_inappwebview.dart'; import 'main.dart'; -class MyChromeSafariBrowser extends PlatformChromeSafariBrowser { +class MyChromeSafariBrowser extends ChromeSafariBrowser { @override void onOpened() { print("ChromeSafari browser opened"); @@ -22,7 +22,7 @@ class MyChromeSafariBrowser extends PlatformChromeSafariBrowser { } class ChromeSafariBrowserExampleScreen extends StatefulWidget { - final PlatformChromeSafariBrowser browser = MyChromeSafariBrowser(); + final ChromeSafariBrowser browser = MyChromeSafariBrowser(); @override _ChromeSafariBrowserExampleScreenState createState() => diff --git a/example/lib/in_app_webiew_example.screen.dart b/example/lib/in_app_webiew_example.screen.dart index a45b8f67..79dc016f 100755 --- a/example/lib/in_app_webiew_example.screen.dart +++ b/example/lib/in_app_webiew_example.screen.dart @@ -15,7 +15,7 @@ class InAppWebViewExampleScreen extends StatefulWidget { class _InAppWebViewExampleScreenState extends State { final GlobalKey webViewKey = GlobalKey(); - PlatformInAppWebViewController? webViewController; + InAppWebViewController? webViewController; InAppWebViewSettings settings = InAppWebViewSettings( isInspectable: kDebugMode, mediaPlaybackRequiresUserGesture: false, diff --git a/flutter_inappwebview_android/lib/src/chrome_safari_browser/chrome_safari_browser.dart b/flutter_inappwebview_android/lib/src/chrome_safari_browser/chrome_safari_browser.dart new file mode 100755 index 00000000..5e1a3309 --- /dev/null +++ b/flutter_inappwebview_android/lib/src/chrome_safari_browser/chrome_safari_browser.dart @@ -0,0 +1,600 @@ +import 'dart:async'; +import 'dart:collection'; +import 'dart:typed_data'; + +import 'package:flutter/foundation.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; + +/// Object specifying creation parameters for creating a [AndroidChromeSafariBrowser]. +/// +/// When adding additional fields make sure they can be null or have a default +/// value to avoid breaking changes. See [PlatformChromeSafariBrowserCreationParams] for +/// more information. +@immutable +class AndroidChromeSafariBrowserCreationParams + extends PlatformChromeSafariBrowserCreationParams { + /// Creates a new [AndroidChromeSafariBrowserCreationParams] instance. + const AndroidChromeSafariBrowserCreationParams(); + + /// Creates a [AndroidChromeSafariBrowserCreationParams] instance based on [PlatformChromeSafariBrowserCreationParams]. + factory AndroidChromeSafariBrowserCreationParams.fromPlatformChromeSafariBrowserCreationParams( + // Recommended placeholder to prevent being broken by platform interface. + // ignore: avoid_unused_constructor_parameters + PlatformChromeSafariBrowserCreationParams params) { + return AndroidChromeSafariBrowserCreationParams(); + } +} + +///This class uses native [Chrome Custom Tabs](https://developer.android.com/reference/android/support/customtabs/package-summary) on Android +///and [SFSafariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller) on iOS. +/// +///**NOTE**: If you want to use the `ChromeSafariBrowser` class on Android 11+ you need to specify your app querying for +///`android.support.customtabs.action.CustomTabsService` in your `AndroidManifest.xml` +///(you can read more about it here: https://developers.google.com/web/android/custom-tabs/best-practices#applications_targeting_android_11_api_level_30_or_above). +/// +///**Supported Platforms/Implementations**: +///- Android +///- iOS +class AndroidChromeSafariBrowser extends PlatformChromeSafariBrowser with ChannelController { + ///Debug settings. + static DebugLoggingSettings debugLoggingSettings = DebugLoggingSettings(); + + ///View ID used internally. + final String id = IdGenerator.generate(); + + /// Constructs a [AndroidChromeSafariBrowser]. + AndroidChromeSafariBrowser(PlatformChromeSafariBrowserCreationParams params) + : super.implementation( + params is AndroidChromeSafariBrowserCreationParams + ? params + : AndroidChromeSafariBrowserCreationParams + .fromPlatformChromeSafariBrowserCreationParams(params), + ); + + static final AndroidChromeSafariBrowser _staticValue = + AndroidChromeSafariBrowser(AndroidChromeSafariBrowserCreationParams()); + + factory AndroidChromeSafariBrowser.static() { + return _staticValue; + } + + ChromeSafariBrowserActionButton? _actionButton; + Map _menuItems = new HashMap(); + ChromeSafariBrowserSecondaryToolbar? _secondaryToolbar; + bool _isOpened = false; + static const MethodChannel _staticChannel = + const MethodChannel('com.pichillilorenzo/flutter_chromesafaribrowser'); + + _init() { + channel = + MethodChannel('com.pichillilorenzo/flutter_chromesafaribrowser_$id'); + handler = _handleMethod; + initMethodCallHandler(); + } + + _debugLog(String method, dynamic args) { + debugLog( + className: this.runtimeType.toString(), + id: id, + debugLoggingSettings: AndroidChromeSafariBrowser.debugLoggingSettings, + method: method, + args: args); + } + + Future _handleMethod(MethodCall call) async { + _debugLog(call.method, call.arguments); + + switch (call.method) { + case "onServiceConnected": + eventHandler?.onServiceConnected(); + break; + case "onOpened": + eventHandler?.onOpened(); + break; + case "onCompletedInitialLoad": + final bool? didLoadSuccessfully = call.arguments["didLoadSuccessfully"]; + eventHandler?.onCompletedInitialLoad(didLoadSuccessfully); + break; + case "onInitialLoadDidRedirect": + final String? url = call.arguments["url"]; + final WebUri? uri = url != null ? WebUri(url) : null; + eventHandler?.onInitialLoadDidRedirect(uri); + break; + case "onNavigationEvent": + final navigationEvent = CustomTabsNavigationEventType.fromNativeValue( + call.arguments["navigationEvent"]); + eventHandler?.onNavigationEvent(navigationEvent); + break; + case "onRelationshipValidationResult": + final relation = + CustomTabsRelationType.fromNativeValue(call.arguments["relation"]); + final requestedOrigin = call.arguments["requestedOrigin"] != null + ? WebUri(call.arguments["requestedOrigin"]) + : null; + final bool result = call.arguments["result"]; + eventHandler?.onRelationshipValidationResult(relation, requestedOrigin, result); + break; + case "onWillOpenInBrowser": + eventHandler?.onWillOpenInBrowser(); + break; + case "onClosed": + _isOpened = false; + dispose(); + eventHandler?.onClosed(); + break; + case "onItemActionPerform": + String url = call.arguments["url"]; + String title = call.arguments["title"]; + int id = call.arguments["id"].toInt(); + if (this._actionButton?.id == id) { + if (this._actionButton?.action != null) { + this._actionButton?.action!(url, title); + } + if (this._actionButton?.onClick != null) { + this._actionButton?.onClick!(WebUri(url), title); + } + } else if (this._menuItems[id] != null) { + if (this._menuItems[id]?.action != null) { + this._menuItems[id]?.action!(url, title); + } + if (this._menuItems[id]?.onClick != null) { + this._menuItems[id]?.onClick!(WebUri(url), title); + } + } + break; + case "onSecondaryItemActionPerform": + final clickableIDs = this._secondaryToolbar?.clickableIDs; + if (clickableIDs != null) { + WebUri? url = call.arguments["url"] != null + ? WebUri(call.arguments["url"]) + : null; + String name = call.arguments["name"]; + for (final clickable in clickableIDs) { + var clickableFullname = clickable.id.name; + if (clickable.id.defType != null && + !clickableFullname.contains("/")) { + clickableFullname = "${clickable.id.defType}/$clickableFullname"; + } + if (clickable.id.defPackage != null && + !clickableFullname.contains(":")) { + clickableFullname = + "${clickable.id.defPackage}:$clickableFullname"; + } + if (clickableFullname == name) { + if (clickable.onClick != null) { + clickable.onClick!(url); + } + break; + } + } + } + break; + case "onMessageChannelReady": + eventHandler?.onMessageChannelReady(); + break; + case "onPostMessage": + final String message = call.arguments["message"]; + eventHandler?.onPostMessage(message); + break; + case "onVerticalScrollEvent": + final bool isDirectionUp = call.arguments["isDirectionUp"]; + eventHandler?.onVerticalScrollEvent(isDirectionUp); + break; + case "onGreatestScrollPercentageIncreased": + final int scrollPercentage = call.arguments["scrollPercentage"]; + eventHandler?.onGreatestScrollPercentageIncreased(scrollPercentage); + break; + case "onSessionEnded": + final bool didUserInteract = call.arguments["didUserInteract"]; + eventHandler?.onSessionEnded(didUserInteract); + break; + default: + throw UnimplementedError("Unimplemented ${call.method} method"); + } + } + + ///Opens the [AndroidChromeSafariBrowser] instance with an [url]. + /// + ///[url] - The [url] to load. On iOS, the [url] is required and must use the `http` or `https` scheme. + /// + ///[headers] (Supported only on Android) - [whitelisted](https://fetch.spec.whatwg.org/#cors-safelisted-request-header) cross-origin request headers. + ///It is possible to attach non-whitelisted headers to cross-origin requests, when the server and client are related using a + ///[digital asset link](https://developers.google.com/digital-asset-links/v1/getting-started). + /// + ///[otherLikelyURLs] - Other likely destinations, sorted in decreasing likelihood order. Supported only on Android. + /// + ///[referrer] - referrer header. Supported only on Android. + /// + ///[options] - Deprecated. Use `settings` instead. + /// + ///[settings] - Settings for the [AndroidChromeSafariBrowser]. + /// + ///**Supported Platforms/Implementations**: + ///- Android + ///- iOS + Future open( + {WebUri? url, + Map? headers, + List? otherLikelyURLs, + WebUri? referrer, + @Deprecated('Use settings instead') + // ignore: deprecated_member_use_from_same_package + ChromeSafariBrowserClassOptions? options, + ChromeSafariBrowserSettings? settings}) async { + assert(!_isOpened, 'The browser is already opened.'); + _isOpened = true; + + if (Util.isIOS) { + assert(url != null, 'The specified URL must not be null on iOS.'); + assert(['http', 'https'].contains(url!.scheme), + 'The specified URL has an unsupported scheme. Only HTTP and HTTPS URLs are supported on iOS.'); + } + if (url != null) { + assert(url.toString().isNotEmpty, 'The specified URL must not be empty.'); + } + + _init(); + + List> menuItemList = []; + _menuItems.forEach((key, value) { + menuItemList.add(value.toMap()); + }); + + var initialSettings = settings?.toMap() ?? + options?.toMap() ?? + ChromeSafariBrowserSettings().toMap(); + + Map args = {}; + args.putIfAbsent('id', () => id); + args.putIfAbsent('url', () => url?.toString()); + args.putIfAbsent('headers', () => headers); + args.putIfAbsent('otherLikelyURLs', + () => otherLikelyURLs?.map((e) => e.toString()).toList()); + args.putIfAbsent('referrer', () => referrer?.toString()); + args.putIfAbsent('settings', () => initialSettings); + args.putIfAbsent('actionButton', () => _actionButton?.toMap()); + args.putIfAbsent('secondaryToolbar', () => _secondaryToolbar?.toMap()); + args.putIfAbsent('menuItemList', () => menuItemList); + await _staticChannel.invokeMethod('open', args); + } + + ///Tells the browser to launch with [url]. + /// + ///[url] - initial url. + /// + ///[headers] (Supported only on Android) - [whitelisted](https://fetch.spec.whatwg.org/#cors-safelisted-request-header) cross-origin request headers. + ///It is possible to attach non-whitelisted headers to cross-origin requests, when the server and client are related using a + ///[digital asset link](https://developers.google.com/digital-asset-links/v1/getting-started). + /// + ///[otherLikelyURLs] - Other likely destinations, sorted in decreasing likelihood order. + /// + ///[referrer] - referrer header. Supported only on Android. + /// + ///**Supported Platforms/Implementations**: + ///- Android + Future launchUrl({ + required WebUri url, + Map? headers, + List? otherLikelyURLs, + WebUri? referrer, + }) async { + Map args = {}; + args.putIfAbsent('url', () => url.toString()); + args.putIfAbsent('headers', () => headers); + args.putIfAbsent('otherLikelyURLs', + () => otherLikelyURLs?.map((e) => e.toString()).toList()); + args.putIfAbsent('referrer', () => referrer?.toString()); + await channel?.invokeMethod("launchUrl", args); + } + + ///Tells the browser of a likely future navigation to a URL. + ///The most likely URL has to be specified first. + ///Optionally, a list of other likely URLs can be provided. + ///They are treated as less likely than the first one, and have to be sorted in decreasing priority order. + ///These additional URLs may be ignored. All previous calls to this method will be deprioritized. + /// + ///[url] - Most likely URL, may be null if otherLikelyBundles is provided. + /// + ///[otherLikelyURLs] - Other likely destinations, sorted in decreasing likelihood order. + /// + ///**Supported Platforms/Implementations**: + ///- Android ([Official API - CustomTabsSession.mayLaunchUrl](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#mayLaunchUrl(android.net.Uri,android.os.Bundle,java.util.List%3Candroid.os.Bundle%3E))) + Future mayLaunchUrl( + {WebUri? url, List? otherLikelyURLs}) async { + Map args = {}; + args.putIfAbsent('url', () => url?.toString()); + args.putIfAbsent('otherLikelyURLs', + () => otherLikelyURLs?.map((e) => e.toString()).toList()); + return await channel?.invokeMethod("mayLaunchUrl", args) ?? false; + } + + ///Requests to validate a relationship between the application and an origin. + /// + ///See [here](https://developers.google.com/digital-asset-links/v1/getting-started) for documentation about Digital Asset Links. + ///This methods requests the browser to verify a relation with the calling application, to grant the associated rights. + /// + ///If this method returns `true`, the validation result will be provided through [onRelationshipValidationResult]. + ///Otherwise the request didn't succeed. + /// + ///[relation] – Relation to check, must be one of the [CustomTabsRelationType] constants. + /// + ///[origin] – Origin. + /// + ///[extras] – Reserved for future use. + /// + ///**Supported Platforms/Implementations**: + ///- Android ([Official API - CustomTabsSession.validateRelationship](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#validateRelationship(int,android.net.Uri,android.os.Bundle))) + Future validateRelationship( + {required CustomTabsRelationType relation, + required WebUri origin}) async { + Map args = {}; + args.putIfAbsent('relation', () => relation.toNativeValue()); + args.putIfAbsent('origin', () => origin.toString()); + return await channel?.invokeMethod("validateRelationship", args) ?? + false; + } + + ///Closes the [AndroidChromeSafariBrowser] instance. + /// + ///**Supported Platforms/Implementations**: + ///- Android + ///- iOS + Future close() async { + Map args = {}; + await channel?.invokeMethod("close", args); + } + + ///Set a custom action button. + /// + ///**NOTE**: Not available in a Trusted Web Activity. + /// + ///**Supported Platforms/Implementations**: + ///- Android ([Official API - CustomTabsIntent.Builder.setActionButton](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsIntent.Builder#setActionButton(android.graphics.Bitmap,%20java.lang.String,%20android.app.PendingIntent,%20boolean))) + void setActionButton(ChromeSafariBrowserActionButton actionButton) { + this._actionButton = actionButton; + } + + ///Updates the [ChromeSafariBrowserActionButton.icon] and [ChromeSafariBrowserActionButton.description]. + /// + ///**NOTE**: Not available in a Trusted Web Activity. + /// + ///**Supported Platforms/Implementations**: + ///- Android ([Official API - CustomTabsSession.setActionButton](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#setActionButton(android.graphics.Bitmap,java.lang.String))) + Future updateActionButton( + {required Uint8List icon, required String description}) async { + Map args = {}; + args.putIfAbsent('icon', () => icon); + args.putIfAbsent('description', () => description); + await channel?.invokeMethod("updateActionButton", args); + _actionButton?.icon = icon; + _actionButton?.description = description; + } + + ///Sets the remote views displayed in the secondary toolbar in a custom tab. + /// + ///**NOTE**: Not available in a Trusted Web Activity. + /// + ///**Supported Platforms/Implementations**: + ///- Android ([Official API - CustomTabsIntent.Builder.setSecondaryToolbarViews](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsIntent.Builder#setSecondaryToolbarViews(android.widget.RemoteViews,int[],android.app.PendingIntent))) + void setSecondaryToolbar( + ChromeSafariBrowserSecondaryToolbar secondaryToolbar) { + this._secondaryToolbar = secondaryToolbar; + } + + ///Sets or updates (if already present) the Remote Views of the secondary toolbar in an existing custom tab session. + /// + ///**NOTE**: Not available in a Trusted Web Activity. + /// + ///**Supported Platforms/Implementations**: + ///- Android ([Official API - CustomTabsSession.setSecondaryToolbarViews](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#setSecondaryToolbarViews(android.widget.RemoteViews,int[],android.app.PendingIntent))) + Future updateSecondaryToolbar( + ChromeSafariBrowserSecondaryToolbar secondaryToolbar) async { + Map args = {}; + args.putIfAbsent('secondaryToolbar', () => secondaryToolbar.toMap()); + await channel?.invokeMethod("updateSecondaryToolbar", args); + this._secondaryToolbar = secondaryToolbar; + } + + ///Adds a [ChromeSafariBrowserMenuItem] to the menu. + /// + ///**NOTE**: Not available in an Android Trusted Web Activity. + /// + ///**Supported Platforms/Implementations**: + ///- Android + ///- iOS + void addMenuItem(ChromeSafariBrowserMenuItem menuItem) { + this._menuItems[menuItem.id] = menuItem; + } + + ///Adds a list of [ChromeSafariBrowserMenuItem] to the menu. + /// + ///**NOTE**: Not available in an Android Trusted Web Activity. + /// + ///**Supported Platforms/Implementations**: + ///- Android + ///- iOS + void addMenuItems(List menuItems) { + menuItems.forEach((menuItem) { + this._menuItems[menuItem.id] = menuItem; + }); + } + + ///Sends a request to create a two way postMessage channel between the client + ///and the browser. + ///If you want to specifying the target origin to communicate with, set the [targetOrigin]. + /// + ///[sourceOrigin] - A origin that the client is requesting to be + ///identified as during the postMessage communication. + ///It has to either start with http or https. + /// + ///[targetOrigin] - The target Origin to establish the postMessage communication with. + ///This can be the app's package name, it has to either start with http or https. + /// + ///Returns whether the implementation accepted the request. + ///Note that returning true here doesn't mean an origin has already been + ///assigned as the validation is asynchronous. + /// + ///**Supported Platforms/Implementations**: + ///- Android ([Official API - CustomTabsSession.requestPostMessageChannel](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#requestPostMessageChannel(android.net.Uri,android.net.Uri,android.os.Bundle))) + Future requestPostMessageChannel( + {required WebUri sourceOrigin, WebUri? targetOrigin}) async { + Map args = {}; + args.putIfAbsent("sourceOrigin", () => sourceOrigin.toString()); + args.putIfAbsent("targetOrigin", () => targetOrigin.toString()); + return await channel?.invokeMethod( + "requestPostMessageChannel", args) ?? + false; + } + + ///Sends a postMessage request using the origin communicated via [requestPostMessageChannel]. + ///Fails when called before [onMessageChannelReady] event. + /// + ///[message] – The message that is being sent. + /// + ///Returns an integer constant about the postMessage request result. + ///Will return CustomTabsService.RESULT_SUCCESS if successful. + /// + ///**Supported Platforms/Implementations**: + ///- Android ([Official API - CustomTabsSession.postMessage](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#postMessage(java.lang.String,android.os.Bundle))) + Future postMessage(String message) async { + Map args = {}; + args.putIfAbsent("message", () => message); + return CustomTabsPostMessageResultType.fromNativeValue( + await channel?.invokeMethod("postMessage", args)) ?? + CustomTabsPostMessageResultType.FAILURE_MESSAGING_ERROR; + } + + ///Returns whether the Engagement Signals API is available. + ///The availability of the Engagement Signals API may change at runtime. + ///If an EngagementSignalsCallback has been set, an [onSessionEnded] + ///signal will be sent if the API becomes unavailable later. + /// + ///Returns whether the Engagement Signals API is available. + /// + ///**Supported Platforms/Implementations**: + ///- Android ([Official API - CustomTabsSession.isEngagementSignalsApiAvailable](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#isEngagementSignalsApiAvailable(android.os.Bundle))) + Future isEngagementSignalsApiAvailable() async { + Map args = {}; + return await channel?.invokeMethod( + "isEngagementSignalsApiAvailable", args) ?? + false; + } + + ///On Android, returns `true` if Chrome Custom Tabs is available. + ///On iOS, returns `true` if SFSafariViewController is available. + ///Otherwise returns `false`. + /// + ///**Supported Platforms/Implementations**: + ///- Android + ///- iOS + Future isAvailable() async { + Map args = {}; + return await _staticChannel.invokeMethod("isAvailable", args) ?? + false; + } + + ///The maximum number of allowed secondary toolbar items. + /// + ///**Supported Platforms/Implementations**: + ///- Android + Future getMaxToolbarItems() async { + Map args = {}; + return await _staticChannel.invokeMethod("getMaxToolbarItems", args) ?? + 0; + } + + ///Returns the preferred package to use for Custom Tabs. + ///The preferred package name is the default VIEW intent handler as long as it supports Custom Tabs. + ///To modify this preferred behavior, set [ignoreDefault] to `true` and give a + ///non empty list of package names in packages. + ///This method queries the `PackageManager` to determine which packages support the Custom Tabs API. + ///On apps that target Android 11 and above, this requires adding the following + ///package visibility elements to your manifest. + /// + ///[packages] – Ordered list of packages to test for Custom Tabs support, in decreasing order of priority. + /// + ///[ignoreDefault] – If set, the default VIEW handler won't get priority over other browsers. + /// + ///Returns the preferred package name for handling Custom Tabs, or null. + /// + ///**Supported Platforms/Implementations**: + ///- Android ([Official API - CustomTabsClient.getPackageName](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsClient#getPackageName(android.content.Context,java.util.List%3Cjava.lang.String%3E,boolean)))) + Future getPackageName( + {List? packages, bool ignoreDefault = false}) async { + Map args = {}; + args.putIfAbsent("packages", () => packages); + args.putIfAbsent("ignoreDefault", () => ignoreDefault); + return await _staticChannel.invokeMethod("getPackageName", args); + } + + ///Clear associated website data accrued from browsing activity within your app. + ///This includes all local storage, cached resources, and cookies. + /// + ///**NOTE for iOS**: available on iOS 16.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - SFSafariViewController.DataStore.clearWebsiteData](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/datastore/3981117-clearwebsitedata)) + Future clearWebsiteData() async { + Map args = {}; + await _staticChannel.invokeMethod("clearWebsiteData", args); + } + + ///Prewarms a connection to each URL. SFSafariViewController will automatically use a + ///prewarmed connection if possible when loading its initial URL. + /// + ///Returns a token object that corresponds to the requested URLs. You must keep a strong + ///reference to this token as long as you expect the prewarmed connections to remain open. If the same + ///server is requested in multiple calls to this method, all of the corresponding tokens must be + ///invalidated or released to end the prewarmed connection to that server. + /// + ///This method uses a best-effort approach to prewarming connections, but may delay + ///or drop requests based on the volume of requests made by your app. Use this method when you expect + ///to present the browser soon. Many HTTP servers time out connections after a few minutes. + ///After a timeout, prewarming delivers less performance benefit. + /// + ///[URLs] - the URLs of servers that the browser should prewarm connections to. + ///Only supports URLs with `http://` or `https://` schemes. + /// + ///**NOTE for iOS**: available on iOS 15.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - SFSafariViewController.prewarmConnections](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/3752133-prewarmconnections)) + Future prewarmConnections(List URLs) async { + Map args = {}; + args.putIfAbsent('URLs', () => URLs.map((e) => e.toString()).toList()); + Map? result = + (await _staticChannel.invokeMethod("prewarmConnections", args)) + ?.cast(); + return PrewarmingToken.fromMap(result); + } + + ///Ends all prewarmed connections associated with the token, except for connections that are also kept alive by other tokens. + /// + ///**NOTE for iOS**: available on iOS 15.0+. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - SFSafariViewController.prewarmConnections](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/3752133-prewarmconnections)) + Future invalidatePrewarmingToken( + PrewarmingToken prewarmingToken) async { + Map args = {}; + args.putIfAbsent('prewarmingToken', () => prewarmingToken.toMap()); + await _staticChannel.invokeMethod("invalidatePrewarmingToken", args); + } + + ///Returns `true` if the [AndroidChromeSafariBrowser] instance is opened, otherwise `false`. + /// + ///**Supported Platforms/Implementations**: + ///- Android + ///- iOS + bool isOpened() { + return _isOpened; + } + + ///Disposes the channel. + @override + @mustCallSuper + void dispose() { + disposeChannel(); + } +} diff --git a/flutter_inappwebview_android/lib/src/chrome_safari_browser/main.dart b/flutter_inappwebview_android/lib/src/chrome_safari_browser/main.dart new file mode 100644 index 00000000..9a6238b7 --- /dev/null +++ b/flutter_inappwebview_android/lib/src/chrome_safari_browser/main.dart @@ -0,0 +1 @@ +export 'chrome_safari_browser.dart'; diff --git a/flutter_inappwebview_android/lib/src/cookie_manager.dart b/flutter_inappwebview_android/lib/src/cookie_manager.dart index 04e44aa5..b817af0c 100755 --- a/flutter_inappwebview_android/lib/src/cookie_manager.dart +++ b/flutter_inappwebview_android/lib/src/cookie_manager.dart @@ -194,7 +194,7 @@ class AndroidCookieManager extends PlatformCookieManager await controller.evaluateJavascript( source: 'document.cookie="$cookieValue"'); setCookieCompleter.complete(); - }, + } )); await headlessWebView.run(); await setCookieCompleter.future; diff --git a/flutter_inappwebview_android/lib/src/in_app_webview/headless_in_app_webview.dart b/flutter_inappwebview_android/lib/src/in_app_webview/headless_in_app_webview.dart index 605254e3..4d33d475 100644 --- a/flutter_inappwebview_android/lib/src/in_app_webview/headless_in_app_webview.dart +++ b/flutter_inappwebview_android/lib/src/in_app_webview/headless_in_app_webview.dart @@ -17,7 +17,8 @@ class AndroidHeadlessInAppWebViewCreationParams extends PlatformHeadlessInAppWebViewCreationParams { /// Creates a new [AndroidHeadlessInAppWebViewCreationParams] instance. AndroidHeadlessInAppWebViewCreationParams( - {super.initialSize, + {super.controllerFromPlatform, + super.initialSize, super.windowId, super.onWebViewCreated, super.onLoadStart, @@ -132,6 +133,7 @@ class AndroidHeadlessInAppWebViewCreationParams AndroidHeadlessInAppWebViewCreationParams.fromPlatformHeadlessInAppWebViewCreationParams( PlatformHeadlessInAppWebViewCreationParams params) : this( + controllerFromPlatform: params.controllerFromPlatform, initialSize: params.initialSize, windowId: params.windowId, onWebViewCreated: params.onWebViewCreated, @@ -288,6 +290,8 @@ class AndroidHeadlessInAppWebView extends PlatformHeadlessInAppWebView @override AndroidInAppWebViewController? get webViewController => _webViewController; + dynamic _controllerFromPlatform; + AndroidHeadlessInAppWebViewCreationParams get _androidParams => params as AndroidHeadlessInAppWebViewCreationParams; @@ -296,6 +300,9 @@ class AndroidHeadlessInAppWebView extends PlatformHeadlessInAppWebView AndroidInAppWebViewControllerCreationParams( id: id, webviewParams: params), ); + _controllerFromPlatform = + params.controllerFromPlatform?.call(_webViewController!) ?? + _webViewController!; _androidParams.pullToRefreshController?.init(id); _androidParams.findInteractionController?.init(id); channel = @@ -308,7 +315,7 @@ class AndroidHeadlessInAppWebView extends PlatformHeadlessInAppWebView switch (call.method) { case "onWebViewCreated": if (params.onWebViewCreated != null && _webViewController != null) { - params.onWebViewCreated!(_webViewController!); + params.onWebViewCreated!(_controllerFromPlatform); } break; default: @@ -478,6 +485,7 @@ class AndroidHeadlessInAppWebView extends PlatformHeadlessInAppWebView _running = false; _webViewController?.dispose(); _webViewController = null; + _controllerFromPlatform = null; _androidParams.pullToRefreshController?.dispose(); _androidParams.findInteractionController?.dispose(); } diff --git a/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview.dart b/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview.dart index 2680aec9..6e8e4756 100755 --- a/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview.dart +++ b/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview.dart @@ -19,7 +19,8 @@ import '../pull_to_refresh/pull_to_refresh_controller.dart'; class AndroidInAppWebViewWidgetCreationParams extends PlatformInAppWebViewWidgetCreationParams { AndroidInAppWebViewWidgetCreationParams( - {super.key, + {super.controllerFromPlatform, + super.key, super.layoutDirection, super.gestureRecognizers, super.headlessWebView, @@ -140,6 +141,7 @@ class AndroidInAppWebViewWidgetCreationParams AndroidInAppWebViewWidgetCreationParams.fromPlatformInAppWebViewWidgetCreationParams( PlatformInAppWebViewWidgetCreationParams params) : this( + controllerFromPlatform: params.controllerFromPlatform, key: params.key, layoutDirection: params.layoutDirection, gestureRecognizers: params.gestureRecognizers, @@ -320,8 +322,6 @@ class AndroidInAppWebViewWidget extends PlatformInAppWebViewWidget { true; return PlatformViewLink( - // Setting a default key using `params` ensures the `PlatformViewLink` - // recreates the PlatformView when changes are made. key: _androidParams.key, viewType: 'com.pichillilorenzo/flutter_inappwebview', surfaceFactory: ( @@ -369,22 +369,6 @@ class AndroidInAppWebViewWidget extends PlatformInAppWebViewWidget { ); } - @override - void dispose() { - dynamic viewId = _controller?.getViewId(); - debugLog( - className: runtimeType.toString(), - id: viewId?.toString(), - debugLoggingSettings: PlatformInAppWebViewController.debugLoggingSettings, - method: "dispose", - args: []); - final isKeepAlive = _androidParams.keepAlive != null; - _controller?.dispose(isKeepAlive: isKeepAlive); - _controller = null; - _androidParams.pullToRefreshController?.dispose(isKeepAlive: isKeepAlive); - _androidParams.findInteractionController?.dispose(isKeepAlive: isKeepAlive); - } - AndroidViewController _createAndroidViewController({ required bool hybridComposition, required int id, @@ -427,11 +411,12 @@ class AndroidInAppWebViewWidget extends PlatformInAppWebViewWidget { debugLog( className: runtimeType.toString(), id: viewId?.toString(), - debugLoggingSettings: PlatformInAppWebViewController.debugLoggingSettings, + debugLoggingSettings: + PlatformInAppWebViewController.debugLoggingSettings, method: "onWebViewCreated", args: []); if (_androidParams.onWebViewCreated != null) { - _androidParams.onWebViewCreated!(_controller!); + _androidParams.onWebViewCreated!(params.controllerFromPlatform?.call(_controller!) ?? _controller!); } } @@ -469,4 +454,27 @@ class AndroidInAppWebViewWidget extends PlatformInAppWebViewWidget { settings.useOnNavigationResponse = true; } } + + @override + void dispose() { + dynamic viewId = _controller?.getViewId(); + debugLog( + className: runtimeType.toString(), + id: viewId?.toString(), + debugLoggingSettings: + PlatformInAppWebViewController.debugLoggingSettings, + method: "dispose", + args: []); + final isKeepAlive = _androidParams.keepAlive != null; + _controller?.dispose(isKeepAlive: isKeepAlive); + _controller = null; + _androidParams.pullToRefreshController?.dispose(isKeepAlive: isKeepAlive); + _androidParams.findInteractionController?.dispose(isKeepAlive: isKeepAlive); + } + + @override + T controllerFromPlatform(PlatformInAppWebViewController controller) { + // TODO: implement controllerFromPlatform + throw UnimplementedError(); + } } diff --git a/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart index 33bc26a3..1596e315 100644 --- a/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart @@ -83,7 +83,11 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController _keepAliveMap = {}; AndroidInAppBrowser? _inAppBrowser; - PlatformInAppBrowserEvents? get _inAppBrowserEventHandler => _inAppBrowser?.eventHandler; + + PlatformInAppBrowserEvents? get _inAppBrowserEventHandler => + _inAppBrowser?.eventHandler; + + dynamic _controllerFromPlatform; ///Provides access to the JavaScript [Web Storage API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API): `window.sessionStorage` and `window.localStorage`. late AndroidWebStorage webStorage; @@ -95,8 +99,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController ? params : AndroidInAppWebViewControllerCreationParams .fromPlatformInAppWebViewControllerCreationParams(params)) { - channel = - MethodChannel('com.pichillilorenzo/flutter_inappwebview_$id'); + channel = MethodChannel('com.pichillilorenzo/flutter_inappwebview_$id'); handler = handleMethod; initMethodCallHandler(); @@ -119,8 +122,9 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController this._init(params); } - static final AndroidInAppWebViewController _staticValue = AndroidInAppWebViewController( - AndroidInAppWebViewControllerCreationParams(id: null)); + static final AndroidInAppWebViewController _staticValue = + AndroidInAppWebViewController( + AndroidInAppWebViewControllerCreationParams(id: null)); factory AndroidInAppWebViewController.static() { return _staticValue; @@ -157,6 +161,9 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController } void _init(PlatformInAppWebViewControllerCreationParams params) { + _controllerFromPlatform = + params.webviewParams?.controllerFromPlatform?.call(this) ?? this; + webStorage = AndroidWebStorage(AndroidWebStorageCreationParams( localStorage: AndroidLocalStorage.defaultStorage(), sessionStorage: AndroidSessionStorage.defaultStorage())); @@ -194,9 +201,12 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController _debugLog(String method, dynamic args) { debugLog( className: this.runtimeType.toString(), - name: _inAppBrowser == null ? "WebView" : _inAppBrowser.runtimeType.toString(), + name: _inAppBrowser == null + ? "WebView" + : _inAppBrowser.runtimeType.toString(), id: (getViewId() ?? _inAppBrowser?.id).toString(), - debugLoggingSettings: PlatformInAppWebViewController.debugLoggingSettings, + debugLoggingSettings: + PlatformInAppWebViewController.debugLoggingSettings, method: method, args: args); } @@ -210,27 +220,23 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController switch (call.method) { case "onLoadStart": _injectedScriptsFromURL.clear(); - if ((webviewParams != null && - webviewParams!.onLoadStart != null) || + if ((webviewParams != null && webviewParams!.onLoadStart != null) || _inAppBrowserEventHandler != null) { String? url = call.arguments["url"]; WebUri? uri = url != null ? WebUri(url) : null; - if (webviewParams != null && - webviewParams!.onLoadStart != null) - webviewParams!.onLoadStart!(this, uri); + if (webviewParams != null && webviewParams!.onLoadStart != null) + webviewParams!.onLoadStart!(_controllerFromPlatform, uri); else _inAppBrowserEventHandler!.onLoadStart(uri); } break; case "onLoadStop": - if ((webviewParams != null && - webviewParams!.onLoadStop != null) || + if ((webviewParams != null && webviewParams!.onLoadStop != null) || _inAppBrowserEventHandler != null) { String? url = call.arguments["url"]; WebUri? uri = url != null ? WebUri(url) : null; - if (webviewParams != null && - webviewParams!.onLoadStop != null) - webviewParams!.onLoadStop!(this, uri); + if (webviewParams != null && webviewParams!.onLoadStop != null) + webviewParams!.onLoadStop!(_controllerFromPlatform, uri); else _inAppBrowserEventHandler!.onLoadStop(uri); } @@ -249,16 +255,17 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null) { if (webviewParams!.onReceivedError != null) - webviewParams!.onReceivedError!(this, request, error); + webviewParams!.onReceivedError!( + _controllerFromPlatform, request, error); else if (isForMainFrame) { // ignore: deprecated_member_use_from_same_package - webviewParams!.onLoadError!(this, request.url, + webviewParams!.onLoadError!(_controllerFromPlatform, request.url, error.type.toNativeValue() ?? -1, error.description); } } else { if (isForMainFrame) { - _inAppBrowserEventHandler!.onLoadError(request.url, error.type.toNativeValue() ?? -1, - error.description); + _inAppBrowserEventHandler!.onLoadError(request.url, + error.type.toNativeValue() ?? -1, error.description); } _inAppBrowserEventHandler!.onReceivedError(request, error); } @@ -279,21 +286,24 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null) { if (webviewParams!.onReceivedHttpError != null) webviewParams!.onReceivedHttpError!( - this, request, errorResponse); + _controllerFromPlatform, request, errorResponse); else if (isForMainFrame) { // ignore: deprecated_member_use_from_same_package webviewParams!.onLoadHttpError!( - this, + _controllerFromPlatform, request.url, errorResponse.statusCode ?? -1, errorResponse.reasonPhrase ?? ''); } } else { if (isForMainFrame) { - _inAppBrowserEventHandler!.onLoadHttpError(request.url, errorResponse.statusCode ?? -1, - errorResponse.reasonPhrase ?? ''); + _inAppBrowserEventHandler!.onLoadHttpError( + request.url, + errorResponse.statusCode ?? -1, + errorResponse.reasonPhrase ?? ''); } - _inAppBrowserEventHandler!.onReceivedHttpError(request, errorResponse); + _inAppBrowserEventHandler! + .onReceivedHttpError(request, errorResponse); } } break; @@ -302,9 +312,9 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController webviewParams!.onProgressChanged != null) || _inAppBrowserEventHandler != null) { int progress = call.arguments["progress"]; - if (webviewParams != null && - webviewParams!.onProgressChanged != null) - webviewParams!.onProgressChanged!(this, progress); + if (webviewParams != null && webviewParams!.onProgressChanged != null) + webviewParams!.onProgressChanged!( + _controllerFromPlatform, progress); else _inAppBrowserEventHandler!.onProgressChanged(progress); } @@ -321,9 +331,10 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null && webviewParams!.shouldOverrideUrlLoading != null) return (await webviewParams!.shouldOverrideUrlLoading!( - this, navigationAction)) + _controllerFromPlatform, navigationAction)) ?.toNativeValue(); - return (await _inAppBrowserEventHandler!.shouldOverrideUrlLoading(navigationAction)) + return (await _inAppBrowserEventHandler! + .shouldOverrideUrlLoading(navigationAction)) ?.toNativeValue(); } break; @@ -334,22 +345,20 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController Map arguments = call.arguments.cast(); ConsoleMessage consoleMessage = ConsoleMessage.fromMap(arguments)!; - if (webviewParams != null && - webviewParams!.onConsoleMessage != null) - webviewParams!.onConsoleMessage!(this, consoleMessage); + if (webviewParams != null && webviewParams!.onConsoleMessage != null) + webviewParams!.onConsoleMessage!( + _controllerFromPlatform, consoleMessage); else _inAppBrowserEventHandler!.onConsoleMessage(consoleMessage); } break; case "onScrollChanged": - if ((webviewParams != null && - webviewParams!.onScrollChanged != null) || + if ((webviewParams != null && webviewParams!.onScrollChanged != null) || _inAppBrowserEventHandler != null) { int x = call.arguments["x"]; int y = call.arguments["y"]; - if (webviewParams != null && - webviewParams!.onScrollChanged != null) - webviewParams!.onScrollChanged!(this, x, y); + if (webviewParams != null && webviewParams!.onScrollChanged != null) + webviewParams!.onScrollChanged!(_controllerFromPlatform, x, y); else _inAppBrowserEventHandler!.onScrollChanged(x, y); } @@ -368,16 +377,18 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null) { if (webviewParams!.onDownloadStartRequest != null) webviewParams!.onDownloadStartRequest!( - this, downloadStartRequest); + _controllerFromPlatform, downloadStartRequest); else { // ignore: deprecated_member_use_from_same_package webviewParams!.onDownloadStart!( - this, downloadStartRequest.url); + _controllerFromPlatform, downloadStartRequest.url); } } else { // ignore: deprecated_member_use_from_same_package - _inAppBrowserEventHandler!.onDownloadStart(downloadStartRequest.url); - _inAppBrowserEventHandler!.onDownloadStartRequest(downloadStartRequest); + _inAppBrowserEventHandler! + .onDownloadStart(downloadStartRequest.url); + _inAppBrowserEventHandler! + .onDownloadStartRequest(downloadStartRequest); } } break; @@ -385,8 +396,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if ((webviewParams != null && (webviewParams!.onLoadResourceWithCustomScheme != null || // ignore: deprecated_member_use_from_same_package - webviewParams!.onLoadResourceCustomScheme != - null)) || + webviewParams!.onLoadResourceCustomScheme != null)) || _inAppBrowserEventHandler != null) { Map requestMap = call.arguments["request"].cast(); @@ -394,85 +404,85 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null) { if (webviewParams!.onLoadResourceWithCustomScheme != null) - return (await webviewParams! - .onLoadResourceWithCustomScheme!(this, request)) + return (await webviewParams!.onLoadResourceWithCustomScheme!( + _controllerFromPlatform, request)) ?.toMap(); else { return (await params - .webviewParams! - // ignore: deprecated_member_use_from_same_package - .onLoadResourceCustomScheme!(this, request.url)) + .webviewParams! + // ignore: deprecated_member_use_from_same_package + .onLoadResourceCustomScheme!( + _controllerFromPlatform, request.url)) ?.toMap(); } } else { - return ((await _inAppBrowserEventHandler!.onLoadResourceWithCustomScheme(request)) ?? - (await _inAppBrowserEventHandler!.onLoadResourceCustomScheme(request.url))) + return ((await _inAppBrowserEventHandler! + .onLoadResourceWithCustomScheme(request)) ?? + (await _inAppBrowserEventHandler! + .onLoadResourceCustomScheme(request.url))) ?.toMap(); } } break; case "onCreateWindow": - if ((webviewParams != null && - webviewParams!.onCreateWindow != null) || + if ((webviewParams != null && webviewParams!.onCreateWindow != null) || _inAppBrowserEventHandler != null) { Map arguments = call.arguments.cast(); CreateWindowAction createWindowAction = CreateWindowAction.fromMap(arguments)!; - if (webviewParams != null && - webviewParams!.onCreateWindow != null) + if (webviewParams != null && webviewParams!.onCreateWindow != null) return await webviewParams!.onCreateWindow!( - this, createWindowAction); + _controllerFromPlatform, createWindowAction); else - return await _inAppBrowserEventHandler!.onCreateWindow(createWindowAction); + return await _inAppBrowserEventHandler! + .onCreateWindow(createWindowAction); } break; case "onCloseWindow": - if (webviewParams != null && - webviewParams!.onCloseWindow != null) - webviewParams!.onCloseWindow!(this); - else if (_inAppBrowserEventHandler != null) _inAppBrowserEventHandler!.onCloseWindow(); + if (webviewParams != null && webviewParams!.onCloseWindow != null) + webviewParams!.onCloseWindow!(_controllerFromPlatform); + else if (_inAppBrowserEventHandler != null) + _inAppBrowserEventHandler!.onCloseWindow(); break; case "onTitleChanged": - if ((webviewParams != null && - webviewParams!.onTitleChanged != null) || + if ((webviewParams != null && webviewParams!.onTitleChanged != null) || _inAppBrowserEventHandler != null) { String? title = call.arguments["title"]; - if (webviewParams != null && - webviewParams!.onTitleChanged != null) - webviewParams!.onTitleChanged!(this, title); + if (webviewParams != null && webviewParams!.onTitleChanged != null) + webviewParams!.onTitleChanged!(_controllerFromPlatform, title); else _inAppBrowserEventHandler!.onTitleChanged(title); } break; case "onGeolocationPermissionsShowPrompt": if ((webviewParams != null && - (webviewParams!.onGeolocationPermissionsShowPrompt != - null || + (webviewParams!.onGeolocationPermissionsShowPrompt != null || // ignore: deprecated_member_use_from_same_package - webviewParams! - .androidOnGeolocationPermissionsShowPrompt != + webviewParams!.androidOnGeolocationPermissionsShowPrompt != null)) || _inAppBrowserEventHandler != null) { String origin = call.arguments["origin"]; if (webviewParams != null) { - if (webviewParams!.onGeolocationPermissionsShowPrompt != - null) - return (await webviewParams! - .onGeolocationPermissionsShowPrompt!(this, origin)) + if (webviewParams!.onGeolocationPermissionsShowPrompt != null) + return (await webviewParams!.onGeolocationPermissionsShowPrompt!( + _controllerFromPlatform, origin)) ?.toMap(); else { return (await params - .webviewParams! - // ignore: deprecated_member_use_from_same_package - .androidOnGeolocationPermissionsShowPrompt!(this, origin)) + .webviewParams! + // ignore: deprecated_member_use_from_same_package + .androidOnGeolocationPermissionsShowPrompt!( + _controllerFromPlatform, origin)) ?.toMap(); } } else { - return ((await _inAppBrowserEventHandler!.onGeolocationPermissionsShowPrompt(origin)) ?? - (await _inAppBrowserEventHandler!.androidOnGeolocationPermissionsShowPrompt(origin))) + return ((await _inAppBrowserEventHandler! + .onGeolocationPermissionsShowPrompt(origin)) ?? + (await _inAppBrowserEventHandler! + .androidOnGeolocationPermissionsShowPrompt(origin))) ?.toMap(); } } @@ -481,28 +491,28 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null && (webviewParams!.onGeolocationPermissionsHidePrompt != null || // ignore: deprecated_member_use_from_same_package - webviewParams! - .androidOnGeolocationPermissionsHidePrompt != + webviewParams!.androidOnGeolocationPermissionsHidePrompt != null)) { if (webviewParams!.onGeolocationPermissionsHidePrompt != null) - webviewParams!.onGeolocationPermissionsHidePrompt!(this); + webviewParams! + .onGeolocationPermissionsHidePrompt!(_controllerFromPlatform); else { // ignore: deprecated_member_use_from_same_package - webviewParams! - .androidOnGeolocationPermissionsHidePrompt!(this); + webviewParams!.androidOnGeolocationPermissionsHidePrompt!( + _controllerFromPlatform); } } else if (_inAppBrowserEventHandler != null) { _inAppBrowserEventHandler!.onGeolocationPermissionsHidePrompt(); // ignore: deprecated_member_use_from_same_package - _inAppBrowserEventHandler!.androidOnGeolocationPermissionsHidePrompt(); + _inAppBrowserEventHandler! + .androidOnGeolocationPermissionsHidePrompt(); } break; case "shouldInterceptRequest": if ((webviewParams != null && (webviewParams!.shouldInterceptRequest != null || // ignore: deprecated_member_use_from_same_package - webviewParams!.androidShouldInterceptRequest != - null)) || + webviewParams!.androidShouldInterceptRequest != null)) || _inAppBrowserEventHandler != null) { Map arguments = call.arguments.cast(); @@ -511,17 +521,19 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null) { if (webviewParams!.shouldInterceptRequest != null) return (await webviewParams!.shouldInterceptRequest!( - this, request)) + _controllerFromPlatform, request)) ?.toMap(); else { // ignore: deprecated_member_use_from_same_package - return (await webviewParams! - .androidShouldInterceptRequest!(this, request)) + return (await webviewParams!.androidShouldInterceptRequest!( + _controllerFromPlatform, request)) ?.toMap(); } } else { - return ((await _inAppBrowserEventHandler!.shouldInterceptRequest(request)) ?? - (await _inAppBrowserEventHandler!.androidShouldInterceptRequest(request))) + return ((await _inAppBrowserEventHandler! + .shouldInterceptRequest(request)) ?? + (await _inAppBrowserEventHandler! + .androidShouldInterceptRequest(request))) ?.toMap(); } } @@ -539,17 +551,19 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null) { if (webviewParams!.onRenderProcessUnresponsive != null) return (await webviewParams!.onRenderProcessUnresponsive!( - this, uri)) + _controllerFromPlatform, uri)) ?.toNativeValue(); else { // ignore: deprecated_member_use_from_same_package - return (await webviewParams! - .androidOnRenderProcessUnresponsive!(this, uri)) + return (await webviewParams!.androidOnRenderProcessUnresponsive!( + _controllerFromPlatform, uri)) ?.toNativeValue(); } } else { - return ((await _inAppBrowserEventHandler!.onRenderProcessUnresponsive(uri)) ?? - (await _inAppBrowserEventHandler!.androidOnRenderProcessUnresponsive(uri))) + return ((await _inAppBrowserEventHandler! + .onRenderProcessUnresponsive(uri)) ?? + (await _inAppBrowserEventHandler! + .androidOnRenderProcessUnresponsive(uri))) ?.toNativeValue(); } } @@ -558,8 +572,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if ((webviewParams != null && (webviewParams!.onRenderProcessResponsive != null || // ignore: deprecated_member_use_from_same_package - webviewParams!.androidOnRenderProcessResponsive != - null)) || + webviewParams!.androidOnRenderProcessResponsive != null)) || _inAppBrowserEventHandler != null) { String? url = call.arguments["url"]; WebUri? uri = url != null ? WebUri(url) : null; @@ -567,17 +580,19 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null) { if (webviewParams!.onRenderProcessResponsive != null) return (await webviewParams!.onRenderProcessResponsive!( - this, uri)) + _controllerFromPlatform, uri)) ?.toNativeValue(); else { // ignore: deprecated_member_use_from_same_package - return (await webviewParams! - .androidOnRenderProcessResponsive!(this, uri)) + return (await webviewParams!.androidOnRenderProcessResponsive!( + _controllerFromPlatform, uri)) ?.toNativeValue(); } } else { - return ((await _inAppBrowserEventHandler!.onRenderProcessResponsive(uri)) ?? - (await _inAppBrowserEventHandler!.androidOnRenderProcessResponsive(uri))) + return ((await _inAppBrowserEventHandler! + .onRenderProcessResponsive(uri)) ?? + (await _inAppBrowserEventHandler! + .androidOnRenderProcessResponsive(uri))) ?.toNativeValue(); } } @@ -586,8 +601,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if ((webviewParams != null && (webviewParams!.onRenderProcessGone != null || // ignore: deprecated_member_use_from_same_package - webviewParams!.androidOnRenderProcessGone != - null)) || + webviewParams!.androidOnRenderProcessGone != null)) || _inAppBrowserEventHandler != null) { Map arguments = call.arguments.cast(); @@ -596,10 +610,12 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null) { if (webviewParams!.onRenderProcessGone != null) - webviewParams!.onRenderProcessGone!(this, detail); + webviewParams!.onRenderProcessGone!( + _controllerFromPlatform, detail); else { // ignore: deprecated_member_use_from_same_package - webviewParams!.androidOnRenderProcessGone!(this, detail); + webviewParams!.androidOnRenderProcessGone!( + _controllerFromPlatform, detail); } } else if (_inAppBrowserEventHandler != null) { _inAppBrowserEventHandler!.onRenderProcessGone(detail); @@ -620,18 +636,20 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null) { if (webviewParams!.onFormResubmission != null) return (await webviewParams!.onFormResubmission!( - this, uri)) + _controllerFromPlatform, uri)) ?.toNativeValue(); else { // ignore: deprecated_member_use_from_same_package return (await webviewParams!.androidOnFormResubmission!( - this, uri)) + _controllerFromPlatform, uri)) ?.toNativeValue(); } } else { - return ((await _inAppBrowserEventHandler!.onFormResubmission(uri)) ?? + return ((await _inAppBrowserEventHandler! + .onFormResubmission(uri)) ?? // ignore: deprecated_member_use_from_same_package - (await _inAppBrowserEventHandler!.androidOnFormResubmission(uri))) + (await _inAppBrowserEventHandler! + .androidOnFormResubmission(uri))) ?.toNativeValue(); } } @@ -648,16 +666,17 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null) { if (webviewParams!.onZoomScaleChanged != null) webviewParams!.onZoomScaleChanged!( - this, oldScale, newScale); + _controllerFromPlatform, oldScale, newScale); else { // ignore: deprecated_member_use_from_same_package webviewParams!.androidOnScaleChanged!( - this, oldScale, newScale); + _controllerFromPlatform, oldScale, newScale); } } else { _inAppBrowserEventHandler!.onZoomScaleChanged(oldScale, newScale); // ignore: deprecated_member_use_from_same_package - _inAppBrowserEventHandler!.androidOnScaleChanged(oldScale, newScale); + _inAppBrowserEventHandler! + .androidOnScaleChanged(oldScale, newScale); } } break; @@ -672,10 +691,11 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null) { if (webviewParams!.onReceivedIcon != null) - webviewParams!.onReceivedIcon!(this, icon); + webviewParams!.onReceivedIcon!(_controllerFromPlatform, icon); else { // ignore: deprecated_member_use_from_same_package - webviewParams!.androidOnReceivedIcon!(this, icon); + webviewParams!.androidOnReceivedIcon!( + _controllerFromPlatform, icon); } } else { _inAppBrowserEventHandler!.onReceivedIcon(icon); @@ -688,8 +708,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if ((webviewParams != null && (webviewParams!.onReceivedTouchIconUrl != null || // ignore: deprecated_member_use_from_same_package - webviewParams!.androidOnReceivedTouchIconUrl != - null)) || + webviewParams!.androidOnReceivedTouchIconUrl != null)) || _inAppBrowserEventHandler != null) { String url = call.arguments["url"]; bool precomposed = call.arguments["precomposed"]; @@ -698,70 +717,69 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null) { if (webviewParams!.onReceivedTouchIconUrl != null) webviewParams!.onReceivedTouchIconUrl!( - this, uri, precomposed); + _controllerFromPlatform, uri, precomposed); else { // ignore: deprecated_member_use_from_same_package webviewParams!.androidOnReceivedTouchIconUrl!( - this, uri, precomposed); + _controllerFromPlatform, uri, precomposed); } } else { _inAppBrowserEventHandler!.onReceivedTouchIconUrl(uri, precomposed); // ignore: deprecated_member_use_from_same_package - _inAppBrowserEventHandler!.androidOnReceivedTouchIconUrl(uri, precomposed); + _inAppBrowserEventHandler! + .androidOnReceivedTouchIconUrl(uri, precomposed); } } break; case "onJsAlert": - if ((webviewParams != null && - webviewParams!.onJsAlert != null) || + if ((webviewParams != null && webviewParams!.onJsAlert != null) || _inAppBrowserEventHandler != null) { Map arguments = call.arguments.cast(); JsAlertRequest jsAlertRequest = JsAlertRequest.fromMap(arguments)!; - if (webviewParams != null && - webviewParams!.onJsAlert != null) + if (webviewParams != null && webviewParams!.onJsAlert != null) return (await webviewParams!.onJsAlert!( - this, jsAlertRequest)) + _controllerFromPlatform, jsAlertRequest)) ?.toMap(); else - return (await _inAppBrowserEventHandler!.onJsAlert(jsAlertRequest))?.toMap(); + return (await _inAppBrowserEventHandler!.onJsAlert(jsAlertRequest)) + ?.toMap(); } break; case "onJsConfirm": - if ((webviewParams != null && - webviewParams!.onJsConfirm != null) || + if ((webviewParams != null && webviewParams!.onJsConfirm != null) || _inAppBrowserEventHandler != null) { Map arguments = call.arguments.cast(); JsConfirmRequest jsConfirmRequest = JsConfirmRequest.fromMap(arguments)!; - if (webviewParams != null && - webviewParams!.onJsConfirm != null) + if (webviewParams != null && webviewParams!.onJsConfirm != null) return (await webviewParams!.onJsConfirm!( - this, jsConfirmRequest)) + _controllerFromPlatform, jsConfirmRequest)) ?.toMap(); else - return (await _inAppBrowserEventHandler!.onJsConfirm(jsConfirmRequest)) + return (await _inAppBrowserEventHandler! + .onJsConfirm(jsConfirmRequest)) ?.toMap(); } break; case "onJsPrompt": - if ((webviewParams != null && - webviewParams!.onJsPrompt != null) || + if ((webviewParams != null && webviewParams!.onJsPrompt != null) || _inAppBrowserEventHandler != null) { Map arguments = call.arguments.cast(); JsPromptRequest jsPromptRequest = JsPromptRequest.fromMap(arguments)!; - if (webviewParams != null && - webviewParams!.onJsPrompt != null) + if (webviewParams != null && webviewParams!.onJsPrompt != null) return (await webviewParams!.onJsPrompt!( - this, jsPromptRequest)) + _controllerFromPlatform, jsPromptRequest)) ?.toMap(); else - return (await _inAppBrowserEventHandler!.onJsPrompt(jsPromptRequest))?.toMap(); + return (await _inAppBrowserEventHandler! + .onJsPrompt(jsPromptRequest)) + ?.toMap(); } break; case "onJsBeforeUnload": @@ -778,17 +796,19 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null) { if (webviewParams!.onJsBeforeUnload != null) return (await webviewParams!.onJsBeforeUnload!( - this, jsBeforeUnloadRequest)) + _controllerFromPlatform, jsBeforeUnloadRequest)) ?.toMap(); else { // ignore: deprecated_member_use_from_same_package return (await webviewParams!.androidOnJsBeforeUnload!( - this, jsBeforeUnloadRequest)) + _controllerFromPlatform, jsBeforeUnloadRequest)) ?.toMap(); } } else { - return ((await _inAppBrowserEventHandler!.onJsBeforeUnload(jsBeforeUnloadRequest)) ?? - (await _inAppBrowserEventHandler!.androidOnJsBeforeUnload(jsBeforeUnloadRequest))) + return ((await _inAppBrowserEventHandler! + .onJsBeforeUnload(jsBeforeUnloadRequest)) ?? + (await _inAppBrowserEventHandler! + .androidOnJsBeforeUnload(jsBeforeUnloadRequest))) ?.toMap(); } } @@ -807,17 +827,19 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null) { if (webviewParams!.onSafeBrowsingHit != null) return (await webviewParams!.onSafeBrowsingHit!( - this, uri, threatType)) + _controllerFromPlatform, uri, threatType)) ?.toMap(); else { // ignore: deprecated_member_use_from_same_package return (await webviewParams!.androidOnSafeBrowsingHit!( - this, uri, threatType)) + _controllerFromPlatform, uri, threatType)) ?.toMap(); } } else { - return ((await _inAppBrowserEventHandler!.onSafeBrowsingHit(uri, threatType)) ?? - (await _inAppBrowserEventHandler!.androidOnSafeBrowsingHit(uri, threatType))) + return ((await _inAppBrowserEventHandler! + .onSafeBrowsingHit(uri, threatType)) ?? + (await _inAppBrowserEventHandler! + .androidOnSafeBrowsingHit(uri, threatType))) ?.toMap(); } } @@ -826,8 +848,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if ((webviewParams != null && (webviewParams!.onReceivedLoginRequest != null || // ignore: deprecated_member_use_from_same_package - webviewParams!.androidOnReceivedLoginRequest != - null)) || + webviewParams!.androidOnReceivedLoginRequest != null)) || _inAppBrowserEventHandler != null) { Map arguments = call.arguments.cast(); @@ -835,16 +856,18 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null) { if (webviewParams!.onReceivedLoginRequest != null) - webviewParams!.onReceivedLoginRequest!(this, loginRequest); + webviewParams!.onReceivedLoginRequest!( + _controllerFromPlatform, loginRequest); else { // ignore: deprecated_member_use_from_same_package webviewParams!.androidOnReceivedLoginRequest!( - this, loginRequest); + _controllerFromPlatform, loginRequest); } } else { _inAppBrowserEventHandler!.onReceivedLoginRequest(loginRequest); // ignore: deprecated_member_use_from_same_package - _inAppBrowserEventHandler!.androidOnReceivedLoginRequest(loginRequest); + _inAppBrowserEventHandler! + .androidOnReceivedLoginRequest(loginRequest); } } break; @@ -860,18 +883,17 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null && webviewParams!.onPermissionRequestCanceled != null) webviewParams!.onPermissionRequestCanceled!( - this, permissionRequest); + _controllerFromPlatform, permissionRequest); else - _inAppBrowserEventHandler!.onPermissionRequestCanceled(permissionRequest); + _inAppBrowserEventHandler! + .onPermissionRequestCanceled(permissionRequest); } break; case "onRequestFocus": - if ((webviewParams != null && - webviewParams!.onRequestFocus != null) || + if ((webviewParams != null && webviewParams!.onRequestFocus != null) || _inAppBrowserEventHandler != null) { - if (webviewParams != null && - webviewParams!.onRequestFocus != null) - webviewParams!.onRequestFocus!(this); + if (webviewParams != null && webviewParams!.onRequestFocus != null) + webviewParams!.onRequestFocus!(_controllerFromPlatform); else _inAppBrowserEventHandler!.onRequestFocus(); } @@ -888,17 +910,17 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null && webviewParams!.onReceivedHttpAuthRequest != null) return (await webviewParams!.onReceivedHttpAuthRequest!( - this, challenge)) + _controllerFromPlatform, challenge)) ?.toMap(); else - return (await _inAppBrowserEventHandler!.onReceivedHttpAuthRequest(challenge)) + return (await _inAppBrowserEventHandler! + .onReceivedHttpAuthRequest(challenge)) ?.toMap(); } break; case "onReceivedServerTrustAuthRequest": if ((webviewParams != null && - webviewParams!.onReceivedServerTrustAuthRequest != - null) || + webviewParams!.onReceivedServerTrustAuthRequest != null) || _inAppBrowserEventHandler != null) { Map arguments = call.arguments.cast(); @@ -907,11 +929,12 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null && webviewParams!.onReceivedServerTrustAuthRequest != null) - return (await webviewParams! - .onReceivedServerTrustAuthRequest!(this, challenge)) + return (await webviewParams!.onReceivedServerTrustAuthRequest!( + _controllerFromPlatform, challenge)) ?.toMap(); else - return (await _inAppBrowserEventHandler!.onReceivedServerTrustAuthRequest(challenge)) + return (await _inAppBrowserEventHandler! + .onReceivedServerTrustAuthRequest(challenge)) ?.toMap(); } break; @@ -927,10 +950,11 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null && webviewParams!.onReceivedClientCertRequest != null) return (await webviewParams!.onReceivedClientCertRequest!( - this, challenge)) + _controllerFromPlatform, challenge)) ?.toMap(); else - return (await _inAppBrowserEventHandler!.onReceivedClientCertRequest(challenge)) + return (await _inAppBrowserEventHandler! + .onReceivedClientCertRequest(challenge)) ?.toMap(); } break; @@ -950,15 +974,15 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController webviewParams!.findInteractionController!.params .onFindResultReceived != null) - webviewParams!.findInteractionController!.params - .onFindResultReceived!( + webviewParams! + .findInteractionController!.params.onFindResultReceived!( webviewParams!.findInteractionController!, activeMatchOrdinal, numberOfMatches, isDoneCounting); else - webviewParams!.onFindResultReceived!( - this, activeMatchOrdinal, numberOfMatches, isDoneCounting); + webviewParams!.onFindResultReceived!(_controllerFromPlatform, + activeMatchOrdinal, numberOfMatches, isDoneCounting); } else { if (_inAppBrowser!.findInteractionController != null && _inAppBrowser! @@ -979,8 +1003,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if ((webviewParams != null && (webviewParams!.onPermissionRequest != null || // ignore: deprecated_member_use_from_same_package - webviewParams!.androidOnPermissionRequest != - null)) || + webviewParams!.androidOnPermissionRequest != null)) || _inAppBrowserEventHandler != null) { String origin = call.arguments["origin"]; List resources = call.arguments["resources"].cast(); @@ -993,18 +1016,20 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null) { if (webviewParams!.onPermissionRequest != null) return (await webviewParams!.onPermissionRequest!( - this, permissionRequest)) + _controllerFromPlatform, permissionRequest)) ?.toMap(); else { // ignore: deprecated_member_use_from_same_package return (await webviewParams!.androidOnPermissionRequest!( - this, origin, resources)) + _controllerFromPlatform, origin, resources)) ?.toMap(); } } else { - return (await _inAppBrowserEventHandler!.onPermissionRequest(permissionRequest)) + return (await _inAppBrowserEventHandler! + .onPermissionRequest(permissionRequest)) ?.toMap() ?? - (await _inAppBrowserEventHandler!.androidOnPermissionRequest(origin, resources)) + (await _inAppBrowserEventHandler! + .androidOnPermissionRequest(origin, resources)) ?.toMap(); } } @@ -1018,7 +1043,8 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController WebUri? uri = url != null ? WebUri(url) : null; if (webviewParams != null && webviewParams!.onUpdateVisitedHistory != null) - webviewParams!.onUpdateVisitedHistory!(this, uri, isReload); + webviewParams!.onUpdateVisitedHistory!( + _controllerFromPlatform, uri, isReload); else _inAppBrowserEventHandler!.onUpdateVisitedHistory(uri, isReload); } @@ -1027,13 +1053,14 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null && (webviewParams!.onWebContentProcessDidTerminate != null || // ignore: deprecated_member_use_from_same_package - webviewParams!.iosOnWebContentProcessDidTerminate != - null)) { + webviewParams!.iosOnWebContentProcessDidTerminate != null)) { if (webviewParams!.onWebContentProcessDidTerminate != null) - webviewParams!.onWebContentProcessDidTerminate!(this); + webviewParams! + .onWebContentProcessDidTerminate!(_controllerFromPlatform); else { // ignore: deprecated_member_use_from_same_package - webviewParams!.iosOnWebContentProcessDidTerminate!(this); + webviewParams! + .iosOnWebContentProcessDidTerminate!(_controllerFromPlatform); } } else if (_inAppBrowserEventHandler != null) { _inAppBrowserEventHandler!.onWebContentProcessDidTerminate(); @@ -1049,7 +1076,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController WebUri? uri = url != null ? WebUri(url) : null; if (webviewParams != null && webviewParams!.onPageCommitVisible != null) - webviewParams!.onPageCommitVisible!(this, uri); + webviewParams!.onPageCommitVisible!(_controllerFromPlatform, uri); else _inAppBrowserEventHandler!.onPageCommitVisible(uri); } @@ -1067,17 +1094,20 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams! .onDidReceiveServerRedirectForProvisionalNavigation != null) - webviewParams! - .onDidReceiveServerRedirectForProvisionalNavigation!(this); + webviewParams!.onDidReceiveServerRedirectForProvisionalNavigation!( + _controllerFromPlatform); else { params - .webviewParams! - // ignore: deprecated_member_use_from_same_package - .iosOnDidReceiveServerRedirectForProvisionalNavigation!(this); + .webviewParams! + // ignore: deprecated_member_use_from_same_package + .iosOnDidReceiveServerRedirectForProvisionalNavigation!( + _controllerFromPlatform); } } else if (_inAppBrowserEventHandler != null) { - _inAppBrowserEventHandler!.onDidReceiveServerRedirectForProvisionalNavigation(); - _inAppBrowserEventHandler!.iosOnDidReceiveServerRedirectForProvisionalNavigation(); + _inAppBrowserEventHandler! + .onDidReceiveServerRedirectForProvisionalNavigation(); + _inAppBrowserEventHandler! + .iosOnDidReceiveServerRedirectForProvisionalNavigation(); } break; case "onNavigationResponse": @@ -1099,18 +1129,20 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null) { if (webviewParams!.onNavigationResponse != null) return (await webviewParams!.onNavigationResponse!( - this, navigationResponse)) + _controllerFromPlatform, navigationResponse)) ?.toNativeValue(); else { // ignore: deprecated_member_use_from_same_package return (await webviewParams!.iosOnNavigationResponse!( - this, iosOnNavigationResponse)) + _controllerFromPlatform, iosOnNavigationResponse)) ?.toNativeValue(); } } else { - return (await _inAppBrowserEventHandler!.onNavigationResponse(navigationResponse)) + return (await _inAppBrowserEventHandler! + .onNavigationResponse(navigationResponse)) ?.toNativeValue() ?? - (await _inAppBrowserEventHandler!.iosOnNavigationResponse(iosOnNavigationResponse)) + (await _inAppBrowserEventHandler! + .iosOnNavigationResponse(iosOnNavigationResponse)) ?.toNativeValue(); } } @@ -1119,8 +1151,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if ((webviewParams != null && (webviewParams!.shouldAllowDeprecatedTLS != null || // ignore: deprecated_member_use_from_same_package - webviewParams!.iosShouldAllowDeprecatedTLS != - null)) || + webviewParams!.iosShouldAllowDeprecatedTLS != null)) || _inAppBrowserEventHandler != null) { Map arguments = call.arguments.cast(); @@ -1130,19 +1161,21 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null) { if (webviewParams!.shouldAllowDeprecatedTLS != null) return (await webviewParams!.shouldAllowDeprecatedTLS!( - this, challenge)) + _controllerFromPlatform, challenge)) ?.toNativeValue(); else { // ignore: deprecated_member_use_from_same_package return (await webviewParams!.iosShouldAllowDeprecatedTLS!( - this, challenge)) + _controllerFromPlatform, challenge)) ?.toNativeValue(); } } else { - return (await _inAppBrowserEventHandler!.shouldAllowDeprecatedTLS(challenge)) + return (await _inAppBrowserEventHandler! + .shouldAllowDeprecatedTLS(challenge)) ?.toNativeValue() ?? // ignore: deprecated_member_use_from_same_package - (await _inAppBrowserEventHandler!.iosShouldAllowDeprecatedTLS(challenge)) + (await _inAppBrowserEventHandler! + .iosShouldAllowDeprecatedTLS(challenge)) ?.toNativeValue(); } } @@ -1159,15 +1192,14 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null && webviewParams!.onLongPressHitTestResult != null) webviewParams!.onLongPressHitTestResult!( - this, hitTestResult); + _controllerFromPlatform, hitTestResult); else _inAppBrowserEventHandler!.onLongPressHitTestResult(hitTestResult); } break; case "onCreateContextMenu": ContextMenu? contextMenu; - if (webviewParams != null && - webviewParams!.contextMenu != null) { + if (webviewParams != null && webviewParams!.contextMenu != null) { contextMenu = webviewParams!.contextMenu; } else if (_inAppBrowserEventHandler != null && _inAppBrowser!.contextMenu != null) { @@ -1185,8 +1217,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController break; case "onHideContextMenu": ContextMenu? contextMenu; - if (webviewParams != null && - webviewParams!.contextMenu != null) { + if (webviewParams != null && webviewParams!.contextMenu != null) { contextMenu = webviewParams!.contextMenu; } else if (_inAppBrowserEventHandler != null && _inAppBrowser!.contextMenu != null) { @@ -1199,8 +1230,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController break; case "onContextMenuActionItemClicked": ContextMenu? contextMenu; - if (webviewParams != null && - webviewParams!.contextMenu != null) { + if (webviewParams != null && webviewParams!.contextMenu != null) { contextMenu = webviewParams!.contextMenu; } else if (_inAppBrowserEventHandler != null && _inAppBrowser!.contextMenu != null) { @@ -1238,45 +1268,43 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController } break; case "onEnterFullscreen": - if (webviewParams != null && - webviewParams!.onEnterFullscreen != null) - webviewParams!.onEnterFullscreen!(this); - else if (_inAppBrowserEventHandler != null) _inAppBrowserEventHandler!.onEnterFullscreen(); + if (webviewParams != null && webviewParams!.onEnterFullscreen != null) + webviewParams!.onEnterFullscreen!(_controllerFromPlatform); + else if (_inAppBrowserEventHandler != null) + _inAppBrowserEventHandler!.onEnterFullscreen(); break; case "onExitFullscreen": - if (webviewParams != null && - webviewParams!.onExitFullscreen != null) - webviewParams!.onExitFullscreen!(this); - else if (_inAppBrowserEventHandler != null) _inAppBrowserEventHandler!.onExitFullscreen(); + if (webviewParams != null && webviewParams!.onExitFullscreen != null) + webviewParams!.onExitFullscreen!(_controllerFromPlatform); + else if (_inAppBrowserEventHandler != null) + _inAppBrowserEventHandler!.onExitFullscreen(); break; case "onOverScrolled": - if ((webviewParams != null && - webviewParams!.onOverScrolled != null) || + if ((webviewParams != null && webviewParams!.onOverScrolled != null) || _inAppBrowserEventHandler != null) { int x = call.arguments["x"]; int y = call.arguments["y"]; bool clampedX = call.arguments["clampedX"]; bool clampedY = call.arguments["clampedY"]; - if (webviewParams != null && - webviewParams!.onOverScrolled != null) + if (webviewParams != null && webviewParams!.onOverScrolled != null) webviewParams!.onOverScrolled!( - this, x, y, clampedX, clampedY); + _controllerFromPlatform, x, y, clampedX, clampedY); else _inAppBrowserEventHandler!.onOverScrolled(x, y, clampedX, clampedY); } break; case "onWindowFocus": - if (webviewParams != null && - webviewParams!.onWindowFocus != null) - webviewParams!.onWindowFocus!(this); - else if (_inAppBrowserEventHandler != null) _inAppBrowserEventHandler!.onWindowFocus(); + if (webviewParams != null && webviewParams!.onWindowFocus != null) + webviewParams!.onWindowFocus!(_controllerFromPlatform); + else if (_inAppBrowserEventHandler != null) + _inAppBrowserEventHandler!.onWindowFocus(); break; case "onWindowBlur": - if (webviewParams != null && - webviewParams!.onWindowBlur != null) - webviewParams!.onWindowBlur!(this); - else if (_inAppBrowserEventHandler != null) _inAppBrowserEventHandler!.onWindowBlur(); + if (webviewParams != null && webviewParams!.onWindowBlur != null) + webviewParams!.onWindowBlur!(_controllerFromPlatform); + else if (_inAppBrowserEventHandler != null) + _inAppBrowserEventHandler!.onWindowBlur(); break; case "onPrintRequest": if ((webviewParams != null && @@ -1295,16 +1323,17 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null) { if (webviewParams!.onPrintRequest != null) return await webviewParams!.onPrintRequest!( - this, uri, printJob); + _controllerFromPlatform, uri, printJob); else { // ignore: deprecated_member_use_from_same_package - webviewParams!.onPrint!(this, uri); + webviewParams!.onPrint!(_controllerFromPlatform, uri); return false; } } else { // ignore: deprecated_member_use_from_same_package _inAppBrowserEventHandler!.onPrint(uri); - return await _inAppBrowserEventHandler!.onPrintRequest(uri, printJob); + return await _inAppBrowserEventHandler! + .onPrintRequest(uri, printJob); } } break; @@ -1336,15 +1365,15 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null && webviewParams!.onCameraCaptureStateChanged != null) webviewParams!.onCameraCaptureStateChanged!( - this, oldState, newState); + _controllerFromPlatform, oldState, newState); else - _inAppBrowserEventHandler!.onCameraCaptureStateChanged(oldState, newState); + _inAppBrowserEventHandler! + .onCameraCaptureStateChanged(oldState, newState); } break; case "onMicrophoneCaptureStateChanged": if ((webviewParams != null && - webviewParams!.onMicrophoneCaptureStateChanged != - null) || + webviewParams!.onMicrophoneCaptureStateChanged != null) || _inAppBrowserEventHandler != null) { var oldState = MediaCaptureState.fromNativeValue(call.arguments["oldState"]); @@ -1354,9 +1383,10 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null && webviewParams!.onMicrophoneCaptureStateChanged != null) webviewParams!.onMicrophoneCaptureStateChanged!( - this, oldState, newState); + _controllerFromPlatform, oldState, newState); else - _inAppBrowserEventHandler!.onMicrophoneCaptureStateChanged(oldState, newState); + _inAppBrowserEventHandler! + .onMicrophoneCaptureStateChanged(oldState, newState); } break; case "onContentSizeChanged": @@ -1371,9 +1401,10 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null && webviewParams!.onContentSizeChanged != null) webviewParams!.onContentSizeChanged!( - this, oldContentSize, newContentSize); + _controllerFromPlatform, oldContentSize, newContentSize); else - _inAppBrowserEventHandler!.onContentSizeChanged(oldContentSize, newContentSize); + _inAppBrowserEventHandler! + .onContentSizeChanged(oldContentSize, newContentSize); } break; case "onCallJsHandler": @@ -1400,7 +1431,8 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null && webviewParams!.onLoadResource != null) - webviewParams!.onLoadResource!(this, response); + webviewParams!.onLoadResource!( + _controllerFromPlatform, response); else _inAppBrowserEventHandler!.onLoadResource(response); } @@ -1414,11 +1446,12 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null && webviewParams!.shouldInterceptAjaxRequest != null) - return jsonEncode(await params - .webviewParams!.shouldInterceptAjaxRequest!(this, request)); - else return jsonEncode( - await _inAppBrowserEventHandler!.shouldInterceptAjaxRequest(request)); + await params.webviewParams!.shouldInterceptAjaxRequest!( + _controllerFromPlatform, request)); + else + return jsonEncode(await _inAppBrowserEventHandler! + .shouldInterceptAjaxRequest(request)); } return null; case "onAjaxReadyStateChange": @@ -1431,10 +1464,11 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null && webviewParams!.onAjaxReadyStateChange != null) return (await webviewParams!.onAjaxReadyStateChange!( - this, request)) + _controllerFromPlatform, request)) ?.toNativeValue(); else - return (await _inAppBrowserEventHandler!.onAjaxReadyStateChange(request)) + return (await _inAppBrowserEventHandler! + .onAjaxReadyStateChange(request)) ?.toNativeValue(); } return null; @@ -1448,41 +1482,42 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (webviewParams != null && webviewParams!.onAjaxProgress != null) return (await webviewParams!.onAjaxProgress!( - this, request)) + _controllerFromPlatform, request)) ?.toNativeValue(); else - return (await _inAppBrowserEventHandler!.onAjaxProgress(request)) + return (await _inAppBrowserEventHandler! + .onAjaxProgress(request)) ?.toNativeValue(); } return null; case "shouldInterceptFetchRequest": if ((webviewParams != null && - webviewParams!.shouldInterceptFetchRequest != - null) || + webviewParams!.shouldInterceptFetchRequest != null) || _inAppBrowserEventHandler != null) { Map arguments = args[0].cast(); FetchRequest request = FetchRequest.fromMap(arguments)!; if (webviewParams != null && webviewParams!.shouldInterceptFetchRequest != null) - return jsonEncode(await webviewParams! - .shouldInterceptFetchRequest!(this, request)); - else return jsonEncode( - await _inAppBrowserEventHandler!.shouldInterceptFetchRequest(request)); + await webviewParams!.shouldInterceptFetchRequest!( + _controllerFromPlatform, request)); + else + return jsonEncode(await _inAppBrowserEventHandler! + .shouldInterceptFetchRequest(request)); } return null; case "onWindowFocus": - if (webviewParams != null && - webviewParams!.onWindowFocus != null) - webviewParams!.onWindowFocus!(this); - else if (_inAppBrowserEventHandler != null) _inAppBrowserEventHandler!.onWindowFocus(); + if (webviewParams != null && webviewParams!.onWindowFocus != null) + webviewParams!.onWindowFocus!(_controllerFromPlatform); + else if (_inAppBrowserEventHandler != null) + _inAppBrowserEventHandler!.onWindowFocus(); return null; case "onWindowBlur": - if (webviewParams != null && - webviewParams!.onWindowBlur != null) - webviewParams!.onWindowBlur!(this); - else if (_inAppBrowserEventHandler != null) _inAppBrowserEventHandler!.onWindowBlur(); + if (webviewParams != null && webviewParams!.onWindowBlur != null) + webviewParams!.onWindowBlur!(_controllerFromPlatform); + else if (_inAppBrowserEventHandler != null) + _inAppBrowserEventHandler!.onWindowBlur(); return null; case "onInjectedScriptLoaded": String id = args[0]; @@ -2957,8 +2992,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController ///- iOS ([Official API - WKUserContentController.addUserScript](https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1537448-adduserscript)) ///- MacOS ([Official API - WKUserContentController.addUserScript](https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1537448-adduserscript)) Future addUserScript({required UserScript userScript}) async { - assert(webviewParams?.windowId == null || - (!Util.isIOS && !Util.isMacOS)); + assert(webviewParams?.windowId == null || (!Util.isIOS && !Util.isMacOS)); Map args = {}; args.putIfAbsent('userScript', () => userScript.toMap()); @@ -2980,8 +3014,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController ///- iOS ///- MacOS Future addUserScripts({required List userScripts}) async { - assert(webviewParams?.windowId == null || - (!Util.isIOS && !Util.isMacOS)); + assert(webviewParams?.windowId == null || (!Util.isIOS && !Util.isMacOS)); for (var i = 0; i < userScripts.length; i++) { await addUserScript(userScript: userScripts[i]); @@ -3001,8 +3034,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController ///- iOS ///- MacOS Future removeUserScript({required UserScript userScript}) async { - assert(webviewParams?.windowId == null || - (!Util.isIOS && !Util.isMacOS)); + assert(webviewParams?.windowId == null || (!Util.isIOS && !Util.isMacOS)); var index = _userScripts[userScript.injectionTime]?.indexOf(userScript); if (index == null || index == -1) { @@ -3030,8 +3062,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController ///- iOS ///- MacOS Future removeUserScriptsByGroupName({required String groupName}) async { - assert(webviewParams?.windowId == null || - (!Util.isIOS && !Util.isMacOS)); + assert(webviewParams?.windowId == null || (!Util.isIOS && !Util.isMacOS)); final List userScriptsAtDocumentStart = List.from( _userScripts[UserScriptInjectionTime.AT_DOCUMENT_START] ?? []); @@ -3067,8 +3098,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController ///- MacOS Future removeUserScripts( {required List userScripts}) async { - assert(webviewParams?.windowId == null || - (!Util.isIOS && !Util.isMacOS)); + assert(webviewParams?.windowId == null || (!Util.isIOS && !Util.isMacOS)); for (final userScript in userScripts) { await removeUserScript(userScript: userScript); @@ -3086,8 +3116,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController ///- iOS ([Official API - WKUserContentController.removeAllUserScripts](https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1536540-removealluserscripts)) ///- MacOS ([Official API - WKUserContentController.removeAllUserScripts](https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1536540-removealluserscripts)) Future removeAllUserScripts() async { - assert(webviewParams?.windowId == null || - (!Util.isIOS && !Util.isMacOS)); + assert(webviewParams?.windowId == null || (!Util.isIOS && !Util.isMacOS)); _userScripts[UserScriptInjectionTime.AT_DOCUMENT_START]?.clear(); _userScripts[UserScriptInjectionTime.AT_DOCUMENT_END]?.clear(); @@ -3405,7 +3434,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController ///```dart /// // Flutter App /// child: InAppWebView( - /// onWebViewCreated: (controller) async { + /// onWebViewCreated: (_controllerFromPlatform) async { /// if (defaultTargetPlatform != TargetPlatform.android || await WebViewFeature.isFeatureSupported(WebViewFeature.WEB_MESSAGE_LISTENER)) { /// await controller.addWebMessageListener(WebMessageListener( /// jsObjectName: "myObject", @@ -4069,6 +4098,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController _inAppBrowser = null; webStorage.dispose(); if (!isKeepAlive) { + _controllerFromPlatform = null; _javaScriptHandlersMap.clear(); _userScripts.clear(); _webMessageListenerObjNames.clear(); diff --git a/flutter_inappwebview_android/lib/src/inappwebview_platform.dart b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart index 6c9bb608..46e73778 100644 --- a/flutter_inappwebview_android/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart @@ -1,6 +1,7 @@ import 'package:flutter_inappwebview_android/src/print_job/main.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; +import 'chrome_safari_browser/chrome_safari_browser.dart'; import 'cookie_manager.dart'; import 'http_auth_credentials_database.dart'; import 'find_interaction/main.dart'; @@ -204,8 +205,8 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { /// This function should only be called by the app-facing package. /// Look at using [InAppBrowser] in `flutter_inappwebview` instead. AndroidInAppBrowser createPlatformInAppBrowser( - PlatformInAppBrowserCreationParams params, - ) { + PlatformInAppBrowserCreationParams params, + ) { return AndroidInAppBrowser(params); } @@ -222,8 +223,8 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { /// This function should only be called by the app-facing package. /// Look at using [ProcessGlobalConfig] in `flutter_inappwebview` instead. AndroidProcessGlobalConfig createPlatformProcessGlobalConfig( - PlatformProcessGlobalConfigCreationParams params, - ) { + PlatformProcessGlobalConfigCreationParams params, + ) { return AndroidProcessGlobalConfig(params); } @@ -232,8 +233,8 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { /// This function should only be called by the app-facing package. /// Look at using [ProxyController] in `flutter_inappwebview` instead. AndroidProxyController createPlatformProxyController( - PlatformProxyControllerCreationParams params, - ) { + PlatformProxyControllerCreationParams params, + ) { return AndroidProxyController(params); } @@ -242,8 +243,8 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { /// This function should only be called by the app-facing package. /// Look at using [ServiceWorkerController] in `flutter_inappwebview` instead. AndroidServiceWorkerController createPlatformServiceWorkerController( - PlatformServiceWorkerControllerCreationParams params, - ) { + PlatformServiceWorkerControllerCreationParams params, + ) { return AndroidServiceWorkerController(params); } @@ -260,36 +261,18 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { /// This function should only be called by the app-facing package. /// Look at using [TracingController] in `flutter_inappwebview` instead. AndroidTracingController createPlatformTracingController( - PlatformTracingControllerCreationParams params, - ) { + PlatformTracingControllerCreationParams params, + ) { return AndroidTracingController(params); } - /// Creates a new [AndroidWebViewAssetLoader]. - /// - /// This function should only be called by the app-facing package. - /// Look at using [WebViewAssetLoader] in `flutter_inappwebview` instead. - AndroidWebViewAssetLoader createPlatformWebViewAssetLoader( - PlatformWebViewAssetLoaderCreationParams params, - ) { - return AndroidWebViewAssetLoader(params); - } - - /// Creates a new empty [AndroidWebViewAssetLoader] to access static methods. - /// - /// This function should only be called by the app-facing package. - /// Look at using [WebViewAssetLoader] in `flutter_inappwebview` instead. - AndroidWebViewAssetLoader createAndroidWebViewAssetLoaderStatic() { - return AndroidWebViewAssetLoader.static(); - } - /// Creates a new [AndroidPathHandler]. /// /// This function should only be called by the app-facing package. /// Look at using [PathHandler] in `flutter_inappwebview` instead. AndroidPathHandler createPlatformPathHandler( - PlatformPathHandlerCreationParams params, - ) { + PlatformPathHandlerCreationParams params, + ) { return AndroidPathHandler(params); } @@ -298,8 +281,8 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { /// This function should only be called by the app-facing package. /// Look at using [AssetsPathHandler] in `flutter_inappwebview` instead. AndroidAssetsPathHandler createPlatformAssetsPathHandler( - PlatformAssetsPathHandlerCreationParams params, - ) { + PlatformAssetsPathHandlerCreationParams params, + ) { return AndroidAssetsPathHandler(params); } @@ -308,8 +291,8 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { /// This function should only be called by the app-facing package. /// Look at using [ResourcesPathHandler] in `flutter_inappwebview` instead. AndroidResourcesPathHandler createPlatformResourcesPathHandler( - PlatformResourcesPathHandlerCreationParams params, - ) { + PlatformResourcesPathHandlerCreationParams params, + ) { return AndroidResourcesPathHandler(params); } @@ -318,8 +301,8 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { /// This function should only be called by the app-facing package. /// Look at using [InternalStoragePathHandler] in `flutter_inappwebview` instead. AndroidInternalStoragePathHandler createPlatformInternalStoragePathHandler( - PlatformInternalStoragePathHandlerCreationParams params, - ) { + PlatformInternalStoragePathHandlerCreationParams params, + ) { return AndroidInternalStoragePathHandler(params); } @@ -328,8 +311,8 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { /// This function should only be called by the app-facing package. /// Look at using [WebViewFeature] in `flutter_inappwebview` instead. wv.AndroidWebViewFeature createPlatformWebViewFeature( - PlatformWebViewFeatureCreationParams params, - ) { + PlatformWebViewFeatureCreationParams params, + ) { return wv.AndroidWebViewFeature(params); } @@ -340,4 +323,31 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { wv.AndroidWebViewFeature createPlatformWebViewFeatureStatic() { return wv.AndroidWebViewFeature.static(); } + + /// Creates a new [AndroidChromeSafariBrowser]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ChromeSafariBrowser] in `flutter_inappwebview` instead. + AndroidChromeSafariBrowser createPlatformChromeSafariBrowser( + PlatformChromeSafariBrowserCreationParams params, + ) { + return AndroidChromeSafariBrowser(params); + } + + /// Creates a new empty [AndroidChromeSafariBrowser] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ChromeSafariBrowser] in `flutter_inappwebview` instead. + AndroidChromeSafariBrowser createPlatformChromeSafariBrowserStatic() { + return AndroidChromeSafariBrowser.static(); + } + + /// Creates a new empty [AndroidWebStorageManager] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebStorageManager] in `flutter_inappwebview` instead. + AndroidWebStorageManager createPlatformWebStorageManager( + PlatformWebStorageManagerCreationParams params) { + return AndroidWebStorageManager(params); + } } diff --git a/flutter_inappwebview_android/lib/src/main.dart b/flutter_inappwebview_android/lib/src/main.dart index d26694c3..84c344d1 100644 --- a/flutter_inappwebview_android/lib/src/main.dart +++ b/flutter_inappwebview_android/lib/src/main.dart @@ -1,7 +1,7 @@ export 'inappwebview_platform.dart'; export 'in_app_webview/main.dart'; export 'in_app_browser/main.dart'; -// export 'chrome_safari_browser/main.dart'; +export 'chrome_safari_browser/main.dart'; export 'web_storage/main.dart'; export 'cookie_manager.dart' hide InternalCookieManager; export 'http_auth_credentials_database.dart' hide InternalHttpAuthCredentialDatabase; @@ -13,9 +13,6 @@ export 'service_worker_controller.dart'; export 'webview_feature.dart' hide InternalWebViewFeature; export 'proxy_controller.dart' hide InternalProxyController; -export 'webview_asset_loader.dart' - hide - InteranlWebViewAssetLoader, - InteranlPathHandler; +export 'webview_asset_loader.dart'; export 'tracing_controller.dart' hide InternalTracingController; export 'process_global_config.dart' hide InternalProcessGlobalConfig; \ No newline at end of file diff --git a/flutter_inappwebview_android/lib/src/webview_asset_loader.dart b/flutter_inappwebview_android/lib/src/webview_asset_loader.dart index b70ce81f..904083e8 100644 --- a/flutter_inappwebview_android/lib/src/webview_asset_loader.dart +++ b/flutter_inappwebview_android/lib/src/webview_asset_loader.dart @@ -2,125 +2,6 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; -/// Object specifying creation parameters for creating a [AndroidWebViewAssetLoader]. -/// -/// When adding additional fields make sure they can be null or have a default -/// value to avoid breaking changes. See [PlatformWebViewAssetLoaderCreationParams] for -/// more information. -@immutable -class AndroidWebViewAssetLoaderCreationParams - extends PlatformWebViewAssetLoaderCreationParams { - /// Creates a new [AndroidWebViewAssetLoaderCreationParams] instance. - const AndroidWebViewAssetLoaderCreationParams( - // This parameter prevents breaking changes later. - // ignore: avoid_unused_constructor_parameters - PlatformWebViewAssetLoaderCreationParams params, - ) : super(); - - /// Creates a [AndroidWebViewAssetLoaderCreationParams] instance based on [PlatformWebViewAssetLoaderCreationParams]. - factory AndroidWebViewAssetLoaderCreationParams.fromPlatformWebViewAssetLoaderCreationParams( - PlatformWebViewAssetLoaderCreationParams params) { - return AndroidWebViewAssetLoaderCreationParams(params); - } -} - -///Helper class to load local files including application's static assets and resources using http(s):// URLs inside a [WebView] class. -///Loading local files using web-like URLs instead of `file://` is desirable as it is compatible with the Same-Origin policy. -/// -///For more context about application's assets and resources and how to normally access them please refer to -///[Android Developer Docs: App resources overview](https://developer.android.com/guide/topics/resources/providing-resources). -/// -///Using http(s):// URLs to access local resources may conflict with a real website. -///This means that local files should only be hosted on domains your organization owns -///(at paths reserved for this purpose) or the default domain reserved for this: `appassets.androidplatform.net`. -/// -///**Supported Platforms/Implementations**: -///- Android native WebView -class AndroidWebViewAssetLoader extends PlatformWebViewAssetLoader { - /// Creates a new [AndroidWebViewAssetLoader]. - AndroidWebViewAssetLoader(PlatformWebViewAssetLoaderCreationParams params) - : super.implementation( - params is AndroidWebViewAssetLoaderCreationParams - ? params - : AndroidWebViewAssetLoaderCreationParams - .fromPlatformWebViewAssetLoaderCreationParams(params), - ); - - factory AndroidWebViewAssetLoader.static() { - return instance(); - } - - static AndroidWebViewAssetLoader? _instance; - - ///Gets the [AndroidWebViewAssetLoader] shared instance. - static AndroidWebViewAssetLoader instance() { - return (_instance != null) ? _instance! : _init(); - } - - static AndroidWebViewAssetLoader _init() { - _instance = AndroidWebViewAssetLoader( - AndroidWebViewAssetLoaderCreationParams( - const PlatformWebViewAssetLoaderCreationParams())); - return _instance!; - } - - ///Set the domain under which app assets can be accessed. The default domain is `appassets.androidplatform.net`. - String? get domain => params.domain; - - ///Allow using the HTTP scheme in addition to HTTPS. The default is to not allow HTTP. - bool? get httpAllowed => params.httpAllowed; - - ///List of registered path handlers. - /// - ///[WebViewAssetLoader] will try Path Handlers in the order they're registered, - ///and will use whichever is the first to return a non-null. - List? get pathHandlers => - params.pathHandlers as List?; - - ///Gets a possible [AndroidWebViewAssetLoader] instance from a [Map] value. - AndroidWebViewAssetLoader? fromMap(Map? map) { - if (map == null) { - return null; - } - final instance = AndroidWebViewAssetLoader( - AndroidWebViewAssetLoaderCreationParams( - PlatformWebViewAssetLoaderCreationParams( - domain: map['domain'], - httpAllowed: map['httpAllowed'], - pathHandlers: map['pathHandlers'] != null - ? List.from(map['pathHandlers'].map((e) => e)) - : null, - ))); - return instance; - } - - ///Converts instance to a map. - Map toMap() { - return { - "domain": domain, - "httpAllowed": httpAllowed, - "pathHandlers": pathHandlers?.map((e) => e.toMap()).toList(), - }; - } - - ///Converts instance to a map. - Map toJson() { - return toMap(); - } - - ///Returns a copy of WebViewAssetLoader. - AndroidWebViewAssetLoader copy() { - return fromMap(toMap()) ?? - AndroidWebViewAssetLoader(AndroidWebViewAssetLoaderCreationParams( - const PlatformWebViewAssetLoaderCreationParams())); - } - - @override - String toString() { - return 'AndroidWebViewAssetLoader{domain: $domain, httpAllowed: $httpAllowed, pathHandlers: $pathHandlers}'; - } -} - /// Object specifying creation parameters for creating a [AndroidPathHandler]. /// /// When adding additional fields make sure they can be null or have a default @@ -346,4 +227,12 @@ class AndroidInternalStoragePathHandler extends AndroidPathHandler implements Pl @override String get directory => _internalParams.directory; + + @override + Map toMap() { + return { + ...toMap(), + 'directory': directory + }; + } } diff --git a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.dart index b3ebbff0..9c464028 100755 --- a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.dart +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.dart @@ -1,21 +1,18 @@ import 'dart:async'; -import 'dart:collection'; -import 'dart:typed_data'; import 'package:flutter/foundation.dart'; -import 'package:flutter/services.dart'; -import '../types/custom_tabs_navigation_event_type.dart'; -import '../types/custom_tabs_post_message_result_type.dart'; -import '../types/custom_tabs_relation_type.dart'; -import '../types/prewarming_token.dart'; -import '../util.dart'; -import '../debug_logging_settings.dart'; +import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; +import 'package:plugin_platform_interface/plugin_platform_interface.dart'; -import '../web_uri.dart'; -import 'chrome_safari_browser_settings.dart'; -import 'chrome_safari_action_button.dart'; -import 'chrome_safari_browser_menu_item.dart'; -import 'chrome_safari_browser_secondary_toolbar.dart'; +/// Object specifying creation parameters for creating a [PlatformChromeSafariBrowser]. +/// +/// Platform specific implementations can add additional fields by extending +/// this class. +@immutable +class PlatformChromeSafariBrowserCreationParams { + /// Used by the platform implementation to create a new [PlatformChromeSafariBrowser]. + const PlatformChromeSafariBrowserCreationParams(); +} ///This class uses native [Chrome Custom Tabs](https://developer.android.com/reference/android/support/customtabs/package-summary) on Android ///and [SFSafariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller) on iOS. @@ -27,156 +24,62 @@ import 'chrome_safari_browser_secondary_toolbar.dart'; ///**Supported Platforms/Implementations**: ///- Android ///- iOS -class PlatformChromeSafariBrowser extends ChannelController { +abstract class PlatformChromeSafariBrowser extends PlatformInterface implements Disposable { ///Debug settings. static DebugLoggingSettings debugLoggingSettings = DebugLoggingSettings(); + /// Event handler object that handles the [PlatformChromeSafariBrowser] events. + PlatformChromeSafariBrowserEvents? eventHandler; + + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.id} ///View ID used internally. - late final String id; - - ChromeSafariBrowserActionButton? _actionButton; - Map _menuItems = new HashMap(); - ChromeSafariBrowserSecondaryToolbar? _secondaryToolbar; - bool _isOpened = false; - static const MethodChannel _sharedChannel = - const MethodChannel('com.pichillilorenzo/flutter_chromesafaribrowser'); - - PlatformChromeSafariBrowser() { - id = IdGenerator.generate(); - channel = - MethodChannel('com.pichillilorenzo/flutter_chromesafaribrowser_$id'); - handler = _handleMethod; - initMethodCallHandler(); - _isOpened = false; + ///@{endtemplate} + String get id { + throw UnimplementedError( + 'id is not implemented on the current platform'); } - _init() { - channel = - MethodChannel('com.pichillilorenzo/flutter_chromesafaribrowser_$id'); - handler = _handleMethod; - initMethodCallHandler(); + /// Creates a new [PlatformChromeSafariBrowser] + factory PlatformChromeSafariBrowser(PlatformChromeSafariBrowserCreationParams params) { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`InAppWebViewPlatform.instance` before use. For unit testing, ' + '`InAppWebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformChromeSafariBrowser chromeSafariBrowser = + InAppWebViewPlatform.instance!.createPlatformChromeSafariBrowser(params); + PlatformInterface.verify(chromeSafariBrowser, _token); + return chromeSafariBrowser; } - _debugLog(String method, dynamic args) { - debugLog( - className: this.runtimeType.toString(), - id: id, - debugLoggingSettings: PlatformChromeSafariBrowser.debugLoggingSettings, - method: method, - args: args); + /// Creates a new [PlatformChromeSafariBrowser] to access static methods. + factory PlatformChromeSafariBrowser.static() { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`InAppWebViewPlatform.instance` before use. For unit testing, ' + '`InAppWebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformChromeSafariBrowser chromeSafariBrowserStatic = + InAppWebViewPlatform.instance!.createPlatformChromeSafariBrowserStatic(); + PlatformInterface.verify(chromeSafariBrowserStatic, _token); + return chromeSafariBrowserStatic; } - Future _handleMethod(MethodCall call) async { - _debugLog(call.method, call.arguments); + /// Used by the platform implementation to create a new [PlatformChromeSafariBrowser]. + /// + /// Should only be used by platform implementations because they can't extend + /// a class that only contains a factory constructor. + @protected + PlatformChromeSafariBrowser.implementation(this.params) : super(token: _token); - switch (call.method) { - case "onServiceConnected": - onServiceConnected(); - break; - case "onOpened": - onOpened(); - break; - case "onCompletedInitialLoad": - final bool? didLoadSuccessfully = call.arguments["didLoadSuccessfully"]; - onCompletedInitialLoad(didLoadSuccessfully); - break; - case "onInitialLoadDidRedirect": - final String? url = call.arguments["url"]; - final WebUri? uri = url != null ? WebUri(url) : null; - onInitialLoadDidRedirect(uri); - break; - case "onNavigationEvent": - final navigationEvent = CustomTabsNavigationEventType.fromNativeValue( - call.arguments["navigationEvent"]); - onNavigationEvent(navigationEvent); - break; - case "onRelationshipValidationResult": - final relation = - CustomTabsRelationType.fromNativeValue(call.arguments["relation"]); - final requestedOrigin = call.arguments["requestedOrigin"] != null - ? WebUri(call.arguments["requestedOrigin"]) - : null; - final bool result = call.arguments["result"]; - onRelationshipValidationResult(relation, requestedOrigin, result); - break; - case "onWillOpenInBrowser": - onWillOpenInBrowser(); - break; - case "onClosed": - _isOpened = false; - dispose(); - onClosed(); - break; - case "onItemActionPerform": - String url = call.arguments["url"]; - String title = call.arguments["title"]; - int id = call.arguments["id"].toInt(); - if (this._actionButton?.id == id) { - if (this._actionButton?.action != null) { - this._actionButton?.action!(url, title); - } - if (this._actionButton?.onClick != null) { - this._actionButton?.onClick!(WebUri(url), title); - } - } else if (this._menuItems[id] != null) { - if (this._menuItems[id]?.action != null) { - this._menuItems[id]?.action!(url, title); - } - if (this._menuItems[id]?.onClick != null) { - this._menuItems[id]?.onClick!(WebUri(url), title); - } - } - break; - case "onSecondaryItemActionPerform": - final clickableIDs = this._secondaryToolbar?.clickableIDs; - if (clickableIDs != null) { - WebUri? url = call.arguments["url"] != null - ? WebUri(call.arguments["url"]) - : null; - String name = call.arguments["name"]; - for (final clickable in clickableIDs) { - var clickableFullname = clickable.id.name; - if (clickable.id.defType != null && - !clickableFullname.contains("/")) { - clickableFullname = "${clickable.id.defType}/$clickableFullname"; - } - if (clickable.id.defPackage != null && - !clickableFullname.contains(":")) { - clickableFullname = - "${clickable.id.defPackage}:$clickableFullname"; - } - if (clickableFullname == name) { - if (clickable.onClick != null) { - clickable.onClick!(url); - } - break; - } - } - } - break; - case "onMessageChannelReady": - onMessageChannelReady(); - break; - case "onPostMessage": - final String message = call.arguments["message"]; - onPostMessage(message); - break; - case "onVerticalScrollEvent": - final bool isDirectionUp = call.arguments["isDirectionUp"]; - onVerticalScrollEvent(isDirectionUp); - break; - case "onGreatestScrollPercentageIncreased": - final int scrollPercentage = call.arguments["scrollPercentage"]; - onGreatestScrollPercentageIncreased(scrollPercentage); - break; - case "onSessionEnded": - final bool didUserInteract = call.arguments["didUserInteract"]; - onSessionEnded(didUserInteract); - break; - default: - throw UnimplementedError("Unimplemented ${call.method} method"); - } - } + static final Object _token = Object(); + + /// The parameters used to initialize the [PlatformChromeSafariBrowser]. + final PlatformChromeSafariBrowserCreationParams params; ///Opens the [PlatformChromeSafariBrowser] instance with an [url]. /// @@ -197,50 +100,16 @@ class PlatformChromeSafariBrowser extends ChannelController { ///**Supported Platforms/Implementations**: ///- Android ///- iOS - Future open( - {WebUri? url, - Map? headers, - List? otherLikelyURLs, - WebUri? referrer, - @Deprecated('Use settings instead') - // ignore: deprecated_member_use_from_same_package - ChromeSafariBrowserClassOptions? options, - ChromeSafariBrowserSettings? settings}) async { - assert(!_isOpened, 'The browser is already opened.'); - _isOpened = true; - - if (Util.isIOS) { - assert(url != null, 'The specified URL must not be null on iOS.'); - assert(['http', 'https'].contains(url!.scheme), - 'The specified URL has an unsupported scheme. Only HTTP and HTTPS URLs are supported on iOS.'); - } - if (url != null) { - assert(url.toString().isNotEmpty, 'The specified URL must not be empty.'); - } - - _init(); - - List> menuItemList = []; - _menuItems.forEach((key, value) { - menuItemList.add(value.toMap()); - }); - - var initialSettings = settings?.toMap() ?? - options?.toMap() ?? - ChromeSafariBrowserSettings().toMap(); - - Map args = {}; - args.putIfAbsent('id', () => id); - args.putIfAbsent('url', () => url?.toString()); - args.putIfAbsent('headers', () => headers); - args.putIfAbsent('otherLikelyURLs', - () => otherLikelyURLs?.map((e) => e.toString()).toList()); - args.putIfAbsent('referrer', () => referrer?.toString()); - args.putIfAbsent('settings', () => initialSettings); - args.putIfAbsent('actionButton', () => _actionButton?.toMap()); - args.putIfAbsent('secondaryToolbar', () => _secondaryToolbar?.toMap()); - args.putIfAbsent('menuItemList', () => menuItemList); - await _sharedChannel.invokeMethod('open', args); + Future open({WebUri? url, + Map? headers, + List? otherLikelyURLs, + WebUri? referrer, + @Deprecated('Use settings instead') + // ignore: deprecated_member_use_from_same_package + ChromeSafariBrowserClassOptions? options, + ChromeSafariBrowserSettings? settings}) { + throw UnimplementedError( + 'open is not implemented on the current platform'); } ///Tells the browser to launch with [url]. @@ -262,14 +131,9 @@ class PlatformChromeSafariBrowser extends ChannelController { Map? headers, List? otherLikelyURLs, WebUri? referrer, - }) async { - Map args = {}; - args.putIfAbsent('url', () => url.toString()); - args.putIfAbsent('headers', () => headers); - args.putIfAbsent('otherLikelyURLs', - () => otherLikelyURLs?.map((e) => e.toString()).toList()); - args.putIfAbsent('referrer', () => referrer?.toString()); - await channel?.invokeMethod("launchUrl", args); + }) { + throw UnimplementedError( + 'launchUrl is not implemented on the current platform'); } ///Tells the browser of a likely future navigation to a URL. @@ -285,12 +149,9 @@ class PlatformChromeSafariBrowser extends ChannelController { ///**Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsSession.mayLaunchUrl](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#mayLaunchUrl(android.net.Uri,android.os.Bundle,java.util.List%3Candroid.os.Bundle%3E))) Future mayLaunchUrl( - {WebUri? url, List? otherLikelyURLs}) async { - Map args = {}; - args.putIfAbsent('url', () => url?.toString()); - args.putIfAbsent('otherLikelyURLs', - () => otherLikelyURLs?.map((e) => e.toString()).toList()); - return await channel?.invokeMethod("mayLaunchUrl", args) ?? false; + {WebUri? url, List? otherLikelyURLs}) { + throw UnimplementedError( + 'mayLaunchUrl is not implemented on the current platform'); } ///Requests to validate a relationship between the application and an origin. @@ -309,14 +170,10 @@ class PlatformChromeSafariBrowser extends ChannelController { /// ///**Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsSession.validateRelationship](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#validateRelationship(int,android.net.Uri,android.os.Bundle))) - Future validateRelationship( - {required CustomTabsRelationType relation, - required WebUri origin}) async { - Map args = {}; - args.putIfAbsent('relation', () => relation.toNativeValue()); - args.putIfAbsent('origin', () => origin.toString()); - return await channel?.invokeMethod("validateRelationship", args) ?? - false; + Future validateRelationship({required CustomTabsRelationType relation, + required WebUri origin}) { + throw UnimplementedError( + 'validateRelationship is not implemented on the current platform'); } ///Closes the [PlatformChromeSafariBrowser] instance. @@ -324,9 +181,9 @@ class PlatformChromeSafariBrowser extends ChannelController { ///**Supported Platforms/Implementations**: ///- Android ///- iOS - Future close() async { - Map args = {}; - await channel?.invokeMethod("close", args); + Future close() { + throw UnimplementedError( + 'close is not implemented on the current platform'); } ///Set a custom action button. @@ -336,7 +193,8 @@ class PlatformChromeSafariBrowser extends ChannelController { ///**Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsIntent.Builder.setActionButton](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsIntent.Builder#setActionButton(android.graphics.Bitmap,%20java.lang.String,%20android.app.PendingIntent,%20boolean))) void setActionButton(ChromeSafariBrowserActionButton actionButton) { - this._actionButton = actionButton; + throw UnimplementedError( + 'setActionButton is not implemented on the current platform'); } ///Updates the [ChromeSafariBrowserActionButton.icon] and [ChromeSafariBrowserActionButton.description]. @@ -346,13 +204,9 @@ class PlatformChromeSafariBrowser extends ChannelController { ///**Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsSession.setActionButton](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#setActionButton(android.graphics.Bitmap,java.lang.String))) Future updateActionButton( - {required Uint8List icon, required String description}) async { - Map args = {}; - args.putIfAbsent('icon', () => icon); - args.putIfAbsent('description', () => description); - await channel?.invokeMethod("updateActionButton", args); - _actionButton?.icon = icon; - _actionButton?.description = description; + {required Uint8List icon, required String description}) { + throw UnimplementedError( + 'updateActionButton is not implemented on the current platform'); } ///Sets the remote views displayed in the secondary toolbar in a custom tab. @@ -363,7 +217,8 @@ class PlatformChromeSafariBrowser extends ChannelController { ///- Android ([Official API - CustomTabsIntent.Builder.setSecondaryToolbarViews](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsIntent.Builder#setSecondaryToolbarViews(android.widget.RemoteViews,int[],android.app.PendingIntent))) void setSecondaryToolbar( ChromeSafariBrowserSecondaryToolbar secondaryToolbar) { - this._secondaryToolbar = secondaryToolbar; + throw UnimplementedError( + 'setSecondaryToolbar is not implemented on the current platform'); } ///Sets or updates (if already present) the Remote Views of the secondary toolbar in an existing custom tab session. @@ -373,11 +228,9 @@ class PlatformChromeSafariBrowser extends ChannelController { ///**Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsSession.setSecondaryToolbarViews](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#setSecondaryToolbarViews(android.widget.RemoteViews,int[],android.app.PendingIntent))) Future updateSecondaryToolbar( - ChromeSafariBrowserSecondaryToolbar secondaryToolbar) async { - Map args = {}; - args.putIfAbsent('secondaryToolbar', () => secondaryToolbar.toMap()); - await channel?.invokeMethod("updateSecondaryToolbar", args); - this._secondaryToolbar = secondaryToolbar; + ChromeSafariBrowserSecondaryToolbar secondaryToolbar) { + throw UnimplementedError( + 'updateSecondaryToolbar is not implemented on the current platform'); } ///Adds a [ChromeSafariBrowserMenuItem] to the menu. @@ -388,7 +241,8 @@ class PlatformChromeSafariBrowser extends ChannelController { ///- Android ///- iOS void addMenuItem(ChromeSafariBrowserMenuItem menuItem) { - this._menuItems[menuItem.id] = menuItem; + throw UnimplementedError( + 'addMenuItem is not implemented on the current platform'); } ///Adds a list of [ChromeSafariBrowserMenuItem] to the menu. @@ -399,9 +253,8 @@ class PlatformChromeSafariBrowser extends ChannelController { ///- Android ///- iOS void addMenuItems(List menuItems) { - menuItems.forEach((menuItem) { - this._menuItems[menuItem.id] = menuItem; - }); + throw UnimplementedError( + 'addMenuItems is not implemented on the current platform'); } ///Sends a request to create a two way postMessage channel between the client @@ -422,13 +275,9 @@ class PlatformChromeSafariBrowser extends ChannelController { ///**Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsSession.requestPostMessageChannel](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#requestPostMessageChannel(android.net.Uri,android.net.Uri,android.os.Bundle))) Future requestPostMessageChannel( - {required WebUri sourceOrigin, WebUri? targetOrigin}) async { - Map args = {}; - args.putIfAbsent("sourceOrigin", () => sourceOrigin.toString()); - args.putIfAbsent("targetOrigin", () => targetOrigin.toString()); - return await channel?.invokeMethod( - "requestPostMessageChannel", args) ?? - false; + {required WebUri sourceOrigin, WebUri? targetOrigin}) { + throw UnimplementedError( + 'requestPostMessageChannel is not implemented on the current platform'); } ///Sends a postMessage request using the origin communicated via [requestPostMessageChannel]. @@ -441,12 +290,9 @@ class PlatformChromeSafariBrowser extends ChannelController { /// ///**Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsSession.postMessage](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#postMessage(java.lang.String,android.os.Bundle))) - Future postMessage(String message) async { - Map args = {}; - args.putIfAbsent("message", () => message); - return CustomTabsPostMessageResultType.fromNativeValue( - await channel?.invokeMethod("postMessage", args)) ?? - CustomTabsPostMessageResultType.FAILURE_MESSAGING_ERROR; + Future postMessage(String message) { + throw UnimplementedError( + 'postMessage is not implemented on the current platform'); } ///Returns whether the Engagement Signals API is available. @@ -458,11 +304,19 @@ class PlatformChromeSafariBrowser extends ChannelController { /// ///**Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsSession.isEngagementSignalsApiAvailable](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#isEngagementSignalsApiAvailable(android.os.Bundle))) - Future isEngagementSignalsApiAvailable() async { - Map args = {}; - return await channel?.invokeMethod( - "isEngagementSignalsApiAvailable", args) ?? - false; + Future isEngagementSignalsApiAvailable() { + throw UnimplementedError( + 'isEngagementSignalsApiAvailable is not implemented on the current platform'); + } + + ///Returns `true` if the [PlatformChromeSafariBrowser] instance is opened, otherwise `false`. + /// + ///**Supported Platforms/Implementations**: + ///- Android + ///- iOS + bool isOpened() { + throw UnimplementedError( + 'isOpened is not implemented on the current platform'); } ///On Android, returns `true` if Chrome Custom Tabs is available. @@ -472,20 +326,18 @@ class PlatformChromeSafariBrowser extends ChannelController { ///**Supported Platforms/Implementations**: ///- Android ///- iOS - static Future isAvailable() async { - Map args = {}; - return await _sharedChannel.invokeMethod("isAvailable", args) ?? - false; + Future isAvailable() { + throw UnimplementedError( + 'isAvailable is not implemented on the current platform'); } ///The maximum number of allowed secondary toolbar items. /// ///**Supported Platforms/Implementations**: ///- Android - static Future getMaxToolbarItems() async { - Map args = {}; - return await _sharedChannel.invokeMethod("getMaxToolbarItems", args) ?? - 0; + Future getMaxToolbarItems() { + throw UnimplementedError( + 'getMaxToolbarItems is not implemented on the current platform'); } ///Returns the preferred package to use for Custom Tabs. @@ -504,12 +356,10 @@ class PlatformChromeSafariBrowser extends ChannelController { /// ///**Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsClient.getPackageName](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsClient#getPackageName(android.content.Context,java.util.List%3Cjava.lang.String%3E,boolean)))) - static Future getPackageName( - {List? packages, bool ignoreDefault = false}) async { - Map args = {}; - args.putIfAbsent("packages", () => packages); - args.putIfAbsent("ignoreDefault", () => ignoreDefault); - return await _sharedChannel.invokeMethod("getPackageName", args); + Future getPackageName( + {List? packages, bool ignoreDefault = false}) { + throw UnimplementedError( + 'getPackageName is not implemented on the current platform'); } ///Clear associated website data accrued from browsing activity within your app. @@ -519,9 +369,9 @@ class PlatformChromeSafariBrowser extends ChannelController { /// ///**Supported Platforms/Implementations**: ///- iOS ([Official API - SFSafariViewController.DataStore.clearWebsiteData](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/datastore/3981117-clearwebsitedata)) - static Future clearWebsiteData() async { - Map args = {}; - await _sharedChannel.invokeMethod("clearWebsiteData", args); + Future clearWebsiteData() { + throw UnimplementedError( + 'clearWebsiteData is not implemented on the current platform'); } ///Prewarms a connection to each URL. SFSafariViewController will automatically use a @@ -544,13 +394,9 @@ class PlatformChromeSafariBrowser extends ChannelController { /// ///**Supported Platforms/Implementations**: ///- iOS ([Official API - SFSafariViewController.prewarmConnections](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/3752133-prewarmconnections)) - static Future prewarmConnections(List URLs) async { - Map args = {}; - args.putIfAbsent('URLs', () => URLs.map((e) => e.toString()).toList()); - Map? result = - (await _sharedChannel.invokeMethod("prewarmConnections", args)) - ?.cast(); - return PrewarmingToken.fromMap(result); + Future prewarmConnections(List URLs) { + throw UnimplementedError( + 'prewarmConnections is not implemented on the current platform'); } ///Ends all prewarmed connections associated with the token, except for connections that are also kept alive by other tokens. @@ -559,13 +405,21 @@ class PlatformChromeSafariBrowser extends ChannelController { /// ///**Supported Platforms/Implementations**: ///- iOS ([Official API - SFSafariViewController.prewarmConnections](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/3752133-prewarmconnections)) - static Future invalidatePrewarmingToken( - PrewarmingToken prewarmingToken) async { - Map args = {}; - args.putIfAbsent('prewarmingToken', () => prewarmingToken.toMap()); - await _sharedChannel.invokeMethod("invalidatePrewarmingToken", args); + Future invalidatePrewarmingToken( + PrewarmingToken prewarmingToken) { + throw UnimplementedError( + 'invalidatePrewarmingToken is not implemented on the current platform'); } + ///Disposes the channel. + @override + void dispose() { + throw UnimplementedError( + 'dispose is not implemented on the current platform'); + } +} + +abstract class PlatformChromeSafariBrowserEvents { ///Event fired when the when connecting from Android Custom Tabs Service. /// ///**Supported Platforms/Implementations**: @@ -678,20 +532,4 @@ class PlatformChromeSafariBrowser extends ChannelController { ///- Android ///- iOS void onClosed() {} - - ///Returns `true` if the [PlatformChromeSafariBrowser] instance is opened, otherwise `false`. - /// - ///**Supported Platforms/Implementations**: - ///- Android - ///- iOS - bool isOpened() { - return _isOpened; - } - - ///Disposes the channel. - @override - @mustCallSuper - void dispose() { - disposeChannel(); - } } diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart index e3ed7bc2..66ad5934 100755 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart @@ -102,7 +102,10 @@ abstract class PlatformInAppBrowser extends PlatformInterface implements Disposa ///WebView Controller that can be used to access the [PlatformInAppWebViewController] API. ///When [onExit] is fired, this will be `null` and cannot be used anymore. ///@{endtemplate} - PlatformInAppWebViewController? get webViewController; + PlatformInAppWebViewController? get webViewController { + throw UnimplementedError( + 'webViewController is not implemented on the current platform'); + } /// Creates a new [PlatformInAppBrowser] factory PlatformInAppBrowser(PlatformInAppBrowserCreationParams params) { diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart index f03914de..fdec8fbe 100755 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart @@ -48,16 +48,6 @@ List _deserializeContentBlockers( return contentBlockers; } -Map? _serializeWebViewAssetLoader( - PlatformWebViewAssetLoader? webViewAssetLoader) { - return webViewAssetLoader?.toMap(); -} - -PlatformWebViewAssetLoader? _deserializeWebViewAssetLoader( - Map? map) { - return PlatformWebViewAssetLoader.static().fromMap(map); -} - ///This class represents all the WebView settings available. @ExchangeableObject(copyMethod: true) class InAppWebViewSettings_ { @@ -381,10 +371,7 @@ because there isn't any way to make the website data store non-persistent for th ///Use a [WebViewAssetLoader] instance to load local files including application's static assets and resources using http(s):// URLs. ///Loading local files using web-like URLs instead of `file://` is desirable as it is compatible with the Same-Origin policy. @SupportedPlatforms(platforms: [AndroidPlatform()]) - @ExchangeableObjectProperty( - serializer: _serializeWebViewAssetLoader, - deserializer: _deserializeWebViewAssetLoader) - PlatformWebViewAssetLoader? webViewAssetLoader; + WebViewAssetLoader_? webViewAssetLoader; ///Sets the text zoom of the page in percent. The default value is `100`. @SupportedPlatforms(platforms: [ diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart index fde15c1a..f211b41d 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart @@ -1170,7 +1170,7 @@ class InAppWebViewSettings { /// ///**Supported Platforms/Implementations**: ///- Android native WebView - PlatformWebViewAssetLoader? webViewAssetLoader; + WebViewAssetLoader? webViewAssetLoader; InAppWebViewSettings( {this.useShouldOverrideUrlLoading, this.useOnLoadResource, @@ -1404,8 +1404,8 @@ class InAppWebViewSettings { ? UtilColor.fromStringRepresentation( map['verticalScrollbarTrackColor']) : null, - webViewAssetLoader: - _deserializeWebViewAssetLoader(map['webViewAssetLoader']), + webViewAssetLoader: WebViewAssetLoader.fromMap( + map['webViewAssetLoader']?.cast()), ); instance.accessibilityIgnoresInvertColors = map['accessibilityIgnoresInvertColors']; @@ -1687,7 +1687,7 @@ class InAppWebViewSettings { "verticalScrollbarPosition": verticalScrollbarPosition?.toNativeValue(), "verticalScrollbarThumbColor": verticalScrollbarThumbColor?.toHex(), "verticalScrollbarTrackColor": verticalScrollbarTrackColor?.toHex(), - "webViewAssetLoader": _serializeWebViewAssetLoader(webViewAssetLoader), + "webViewAssetLoader": webViewAssetLoader?.toMap(), }; } diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_headless_in_app_webview.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_headless_in_app_webview.dart index dda312c9..62c791e0 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_headless_in_app_webview.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_headless_in_app_webview.dart @@ -17,115 +17,116 @@ class PlatformHeadlessInAppWebViewCreationParams /// Used by the platform implementation to create a new [PlatformHeadlessInAppWebView]. const PlatformHeadlessInAppWebViewCreationParams( {this.initialSize = const Size(-1, -1), - super.windowId, - super.onWebViewCreated, - super.onLoadStart, - super.onLoadStop, - @Deprecated('Use onReceivedError instead') super.onLoadError, - super.onReceivedError, - @Deprecated("Use onReceivedHttpError instead") super.onLoadHttpError, - super.onReceivedHttpError, - super.onProgressChanged, - super.onConsoleMessage, - super.shouldOverrideUrlLoading, - super.onLoadResource, - super.onScrollChanged, - @Deprecated('Use onDownloadStartRequest instead') super.onDownloadStart, - super.onDownloadStartRequest, - @Deprecated('Use onLoadResourceWithCustomScheme instead') - super.onLoadResourceCustomScheme, - super.onLoadResourceWithCustomScheme, - super.onCreateWindow, - super.onCloseWindow, - super.onJsAlert, - super.onJsConfirm, - super.onJsPrompt, - super.onReceivedHttpAuthRequest, - super.onReceivedServerTrustAuthRequest, - super.onReceivedClientCertRequest, - @Deprecated('Use FindInteractionController.onFindResultReceived instead') - super.onFindResultReceived, - super.shouldInterceptAjaxRequest, - super.onAjaxReadyStateChange, - super.onAjaxProgress, - super.shouldInterceptFetchRequest, - super.onUpdateVisitedHistory, - @Deprecated("Use onPrintRequest instead") super.onPrint, - super.onPrintRequest, - super.onLongPressHitTestResult, - super.onEnterFullscreen, - super.onExitFullscreen, - super.onPageCommitVisible, - super.onTitleChanged, - super.onWindowFocus, - super.onWindowBlur, - super.onOverScrolled, - super.onZoomScaleChanged, - @Deprecated('Use onSafeBrowsingHit instead') - super.androidOnSafeBrowsingHit, - super.onSafeBrowsingHit, - @Deprecated('Use onPermissionRequest instead') - super.androidOnPermissionRequest, - super.onPermissionRequest, - @Deprecated('Use onGeolocationPermissionsShowPrompt instead') - super.androidOnGeolocationPermissionsShowPrompt, - super.onGeolocationPermissionsShowPrompt, - @Deprecated('Use onGeolocationPermissionsHidePrompt instead') - super.androidOnGeolocationPermissionsHidePrompt, - super.onGeolocationPermissionsHidePrompt, - @Deprecated('Use shouldInterceptRequest instead') - super.androidShouldInterceptRequest, - super.shouldInterceptRequest, - @Deprecated('Use onRenderProcessGone instead') - super.androidOnRenderProcessGone, - super.onRenderProcessGone, - @Deprecated('Use onRenderProcessResponsive instead') - super.androidOnRenderProcessResponsive, - super.onRenderProcessResponsive, - @Deprecated('Use onRenderProcessUnresponsive instead') - super.androidOnRenderProcessUnresponsive, - super.onRenderProcessUnresponsive, - @Deprecated('Use onFormResubmission instead') - super.androidOnFormResubmission, - super.onFormResubmission, - @Deprecated('Use onZoomScaleChanged instead') super.androidOnScaleChanged, - @Deprecated('Use onReceivedIcon instead') super.androidOnReceivedIcon, - super.onReceivedIcon, - @Deprecated('Use onReceivedTouchIconUrl instead') - super.androidOnReceivedTouchIconUrl, - super.onReceivedTouchIconUrl, - @Deprecated('Use onJsBeforeUnload instead') super.androidOnJsBeforeUnload, - super.onJsBeforeUnload, - @Deprecated('Use onReceivedLoginRequest instead') - super.androidOnReceivedLoginRequest, - super.onReceivedLoginRequest, - super.onPermissionRequestCanceled, - super.onRequestFocus, - @Deprecated('Use onWebContentProcessDidTerminate instead') - super.iosOnWebContentProcessDidTerminate, - super.onWebContentProcessDidTerminate, - @Deprecated( - 'Use onDidReceiveServerRedirectForProvisionalNavigation instead') - super.iosOnDidReceiveServerRedirectForProvisionalNavigation, - super.onDidReceiveServerRedirectForProvisionalNavigation, - @Deprecated('Use onNavigationResponse instead') - super.iosOnNavigationResponse, - super.onNavigationResponse, - @Deprecated('Use shouldAllowDeprecatedTLS instead') - super.iosShouldAllowDeprecatedTLS, - super.shouldAllowDeprecatedTLS, - super.onCameraCaptureStateChanged, - super.onMicrophoneCaptureStateChanged, - super.onContentSizeChanged, - super.initialUrlRequest, - super.initialFile, - super.initialData, - @Deprecated('Use initialSettings instead') super.initialOptions, - super.initialSettings, - super.contextMenu, - super.initialUserScripts, - super.pullToRefreshController, - super.findInteractionController}); + super.controllerFromPlatform, + super.windowId, + super.onWebViewCreated, + super.onLoadStart, + super.onLoadStop, + @Deprecated('Use onReceivedError instead') super.onLoadError, + super.onReceivedError, + @Deprecated("Use onReceivedHttpError instead") super.onLoadHttpError, + super.onReceivedHttpError, + super.onProgressChanged, + super.onConsoleMessage, + super.shouldOverrideUrlLoading, + super.onLoadResource, + super.onScrollChanged, + @Deprecated('Use onDownloadStartRequest instead') super.onDownloadStart, + super.onDownloadStartRequest, + @Deprecated('Use onLoadResourceWithCustomScheme instead') + super.onLoadResourceCustomScheme, + super.onLoadResourceWithCustomScheme, + super.onCreateWindow, + super.onCloseWindow, + super.onJsAlert, + super.onJsConfirm, + super.onJsPrompt, + super.onReceivedHttpAuthRequest, + super.onReceivedServerTrustAuthRequest, + super.onReceivedClientCertRequest, + @Deprecated('Use FindInteractionController.onFindResultReceived instead') + super.onFindResultReceived, + super.shouldInterceptAjaxRequest, + super.onAjaxReadyStateChange, + super.onAjaxProgress, + super.shouldInterceptFetchRequest, + super.onUpdateVisitedHistory, + @Deprecated("Use onPrintRequest instead") super.onPrint, + super.onPrintRequest, + super.onLongPressHitTestResult, + super.onEnterFullscreen, + super.onExitFullscreen, + super.onPageCommitVisible, + super.onTitleChanged, + super.onWindowFocus, + super.onWindowBlur, + super.onOverScrolled, + super.onZoomScaleChanged, + @Deprecated('Use onSafeBrowsingHit instead') + super.androidOnSafeBrowsingHit, + super.onSafeBrowsingHit, + @Deprecated('Use onPermissionRequest instead') + super.androidOnPermissionRequest, + super.onPermissionRequest, + @Deprecated('Use onGeolocationPermissionsShowPrompt instead') + super.androidOnGeolocationPermissionsShowPrompt, + super.onGeolocationPermissionsShowPrompt, + @Deprecated('Use onGeolocationPermissionsHidePrompt instead') + super.androidOnGeolocationPermissionsHidePrompt, + super.onGeolocationPermissionsHidePrompt, + @Deprecated('Use shouldInterceptRequest instead') + super.androidShouldInterceptRequest, + super.shouldInterceptRequest, + @Deprecated('Use onRenderProcessGone instead') + super.androidOnRenderProcessGone, + super.onRenderProcessGone, + @Deprecated('Use onRenderProcessResponsive instead') + super.androidOnRenderProcessResponsive, + super.onRenderProcessResponsive, + @Deprecated('Use onRenderProcessUnresponsive instead') + super.androidOnRenderProcessUnresponsive, + super.onRenderProcessUnresponsive, + @Deprecated('Use onFormResubmission instead') + super.androidOnFormResubmission, + super.onFormResubmission, + @Deprecated('Use onZoomScaleChanged instead') super.androidOnScaleChanged, + @Deprecated('Use onReceivedIcon instead') super.androidOnReceivedIcon, + super.onReceivedIcon, + @Deprecated('Use onReceivedTouchIconUrl instead') + super.androidOnReceivedTouchIconUrl, + super.onReceivedTouchIconUrl, + @Deprecated('Use onJsBeforeUnload instead') super.androidOnJsBeforeUnload, + super.onJsBeforeUnload, + @Deprecated('Use onReceivedLoginRequest instead') + super.androidOnReceivedLoginRequest, + super.onReceivedLoginRequest, + super.onPermissionRequestCanceled, + super.onRequestFocus, + @Deprecated('Use onWebContentProcessDidTerminate instead') + super.iosOnWebContentProcessDidTerminate, + super.onWebContentProcessDidTerminate, + @Deprecated( + 'Use onDidReceiveServerRedirectForProvisionalNavigation instead') + super.iosOnDidReceiveServerRedirectForProvisionalNavigation, + super.onDidReceiveServerRedirectForProvisionalNavigation, + @Deprecated('Use onNavigationResponse instead') + super.iosOnNavigationResponse, + super.onNavigationResponse, + @Deprecated('Use shouldAllowDeprecatedTLS instead') + super.iosShouldAllowDeprecatedTLS, + super.shouldAllowDeprecatedTLS, + super.onCameraCaptureStateChanged, + super.onMicrophoneCaptureStateChanged, + super.onContentSizeChanged, + super.initialUrlRequest, + super.initialFile, + super.initialData, + @Deprecated('Use initialSettings instead') super.initialOptions, + super.initialSettings, + super.contextMenu, + super.initialUserScripts, + super.pullToRefreshController, + super.findInteractionController}); ///The WebView initial size in pixels. /// @@ -154,19 +155,21 @@ class PlatformHeadlessInAppWebViewCreationParams ///- Web ///- MacOS ///{@endtemplate} -abstract class PlatformHeadlessInAppWebView extends PlatformInterface implements Disposable { +abstract class PlatformHeadlessInAppWebView extends PlatformInterface + implements Disposable { /// Creates a new [PlatformHeadlessInAppWebView] factory PlatformHeadlessInAppWebView( PlatformHeadlessInAppWebViewCreationParams params) { assert( - InAppWebViewPlatform.instance != null, - 'A platform implementation for `flutter_inappwebview` has not been set. Please ' - 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' - '`InAppWebViewPlatform.instance` before use. For unit testing, ' - '`InAppWebViewPlatform.instance` can be set with your own test implementation.', + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`InAppWebViewPlatform.instance` before use. For unit testing, ' + '`InAppWebViewPlatform.instance` can be set with your own test implementation.', ); final PlatformHeadlessInAppWebView webViewControllerDelegate = - InAppWebViewPlatform.instance!.createPlatformHeadlessInAppWebView(params); + InAppWebViewPlatform.instance! + .createPlatformHeadlessInAppWebView(params); PlatformInterface.verify(webViewControllerDelegate, _token); return webViewControllerDelegate; } @@ -176,7 +179,8 @@ abstract class PlatformHeadlessInAppWebView extends PlatformInterface implements /// Should only be used by platform implementations because they can't extend /// a class that only contains a factory constructor. @protected - PlatformHeadlessInAppWebView.implementation(this.params) : super(token: _token); + PlatformHeadlessInAppWebView.implementation(this.params) + : super(token: _token); static final Object _token = Object(); @@ -184,12 +188,13 @@ abstract class PlatformHeadlessInAppWebView extends PlatformInterface implements final PlatformHeadlessInAppWebViewCreationParams params; ///WebView Controller that can be used to access the [InAppWebViewController] API. - PlatformInAppWebViewController? get webViewController => throw UnimplementedError( - 'webViewController is not implemented on the current platform'); + PlatformInAppWebViewController? get webViewController => + throw UnimplementedError( + 'webViewController is not implemented on the current platform'); ///View ID. - String get id => throw UnimplementedError( - 'id is not implemented on the current platform'); + String get id => + throw UnimplementedError('id is not implemented on the current platform'); ///Runs the headless WebView. /// @@ -201,8 +206,7 @@ abstract class PlatformHeadlessInAppWebView extends PlatformInterface implements ///- Web ///- MacOS Future run() { - throw UnimplementedError( - 'run is not implemented on the current platform'); + throw UnimplementedError('run is not implemented on the current platform'); } ///Indicates if the headless WebView is running or not. @@ -262,4 +266,3 @@ abstract class PlatformHeadlessInAppWebView extends PlatformInterface implements 'dispose is not implemented on the current platform'); } } - diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_widget.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_widget.dart index e7440b03..64294032 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_widget.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_widget.dart @@ -8,6 +8,7 @@ import '../types/disposable.dart'; import 'in_app_webview_keep_alive.dart'; import 'platform_webview.dart'; import 'platform_headless_in_app_webview.dart'; +import 'platform_inappwebview_controller.dart'; /// Object specifying creation parameters for creating a [PlatformInAppWebViewWidget]. /// @@ -18,120 +19,121 @@ class PlatformInAppWebViewWidgetCreationParams /// Used by the platform implementation to create a new [PlatformInAppWebViewWidget]. PlatformInAppWebViewWidgetCreationParams( {this.key, - this.layoutDirection, - this.gestureRecognizers, - this.headlessWebView, - this.keepAlive, - this.preventGestureDelay, - super.windowId, - super.onWebViewCreated, - super.onLoadStart, - super.onLoadStop, - @Deprecated('Use onReceivedError instead') super.onLoadError, - super.onReceivedError, - @Deprecated("Use onReceivedHttpError instead") super.onLoadHttpError, - super.onReceivedHttpError, - super.onProgressChanged, - super.onConsoleMessage, - super.shouldOverrideUrlLoading, - super.onLoadResource, - super.onScrollChanged, - @Deprecated('Use onDownloadStartRequest instead') super.onDownloadStart, - super.onDownloadStartRequest, - @Deprecated('Use onLoadResourceWithCustomScheme instead') - super.onLoadResourceCustomScheme, - super.onLoadResourceWithCustomScheme, - super.onCreateWindow, - super.onCloseWindow, - super.onJsAlert, - super.onJsConfirm, - super.onJsPrompt, - super.onReceivedHttpAuthRequest, - super.onReceivedServerTrustAuthRequest, - super.onReceivedClientCertRequest, - @Deprecated('Use FindInteractionController.onFindResultReceived instead') - super.onFindResultReceived, - super.shouldInterceptAjaxRequest, - super.onAjaxReadyStateChange, - super.onAjaxProgress, - super.shouldInterceptFetchRequest, - super.onUpdateVisitedHistory, - @Deprecated("Use onPrintRequest instead") super.onPrint, - super.onPrintRequest, - super.onLongPressHitTestResult, - super.onEnterFullscreen, - super.onExitFullscreen, - super.onPageCommitVisible, - super.onTitleChanged, - super.onWindowFocus, - super.onWindowBlur, - super.onOverScrolled, - super.onZoomScaleChanged, - @Deprecated('Use onSafeBrowsingHit instead') - super.androidOnSafeBrowsingHit, - super.onSafeBrowsingHit, - @Deprecated('Use onPermissionRequest instead') - super.androidOnPermissionRequest, - super.onPermissionRequest, - @Deprecated('Use onGeolocationPermissionsShowPrompt instead') - super.androidOnGeolocationPermissionsShowPrompt, - super.onGeolocationPermissionsShowPrompt, - @Deprecated('Use onGeolocationPermissionsHidePrompt instead') - super.androidOnGeolocationPermissionsHidePrompt, - super.onGeolocationPermissionsHidePrompt, - @Deprecated('Use shouldInterceptRequest instead') - super.androidShouldInterceptRequest, - super.shouldInterceptRequest, - @Deprecated('Use onRenderProcessGone instead') - super.androidOnRenderProcessGone, - super.onRenderProcessGone, - @Deprecated('Use onRenderProcessResponsive instead') - super.androidOnRenderProcessResponsive, - super.onRenderProcessResponsive, - @Deprecated('Use onRenderProcessUnresponsive instead') - super.androidOnRenderProcessUnresponsive, - super.onRenderProcessUnresponsive, - @Deprecated('Use onFormResubmission instead') - super.androidOnFormResubmission, - super.onFormResubmission, - @Deprecated('Use onZoomScaleChanged instead') super.androidOnScaleChanged, - @Deprecated('Use onReceivedIcon instead') super.androidOnReceivedIcon, - super.onReceivedIcon, - @Deprecated('Use onReceivedTouchIconUrl instead') - super.androidOnReceivedTouchIconUrl, - super.onReceivedTouchIconUrl, - @Deprecated('Use onJsBeforeUnload instead') super.androidOnJsBeforeUnload, - super.onJsBeforeUnload, - @Deprecated('Use onReceivedLoginRequest instead') - super.androidOnReceivedLoginRequest, - super.onReceivedLoginRequest, - super.onPermissionRequestCanceled, - super.onRequestFocus, - @Deprecated('Use onWebContentProcessDidTerminate instead') - super.iosOnWebContentProcessDidTerminate, - super.onWebContentProcessDidTerminate, - @Deprecated( - 'Use onDidReceiveServerRedirectForProvisionalNavigation instead') - super.iosOnDidReceiveServerRedirectForProvisionalNavigation, - super.onDidReceiveServerRedirectForProvisionalNavigation, - @Deprecated('Use onNavigationResponse instead') - super.iosOnNavigationResponse, - super.onNavigationResponse, - @Deprecated('Use shouldAllowDeprecatedTLS instead') - super.iosShouldAllowDeprecatedTLS, - super.shouldAllowDeprecatedTLS, - super.onCameraCaptureStateChanged, - super.onMicrophoneCaptureStateChanged, - super.onContentSizeChanged, - super.initialUrlRequest, - super.initialFile, - super.initialData, - @Deprecated('Use initialSettings instead') super.initialOptions, - super.initialSettings, - super.contextMenu, - super.initialUserScripts, - super.pullToRefreshController, - super.findInteractionController}); + this.layoutDirection, + this.gestureRecognizers, + this.headlessWebView, + this.keepAlive, + this.preventGestureDelay, + super.controllerFromPlatform, + super.windowId, + super.onWebViewCreated, + super.onLoadStart, + super.onLoadStop, + @Deprecated('Use onReceivedError instead') super.onLoadError, + super.onReceivedError, + @Deprecated("Use onReceivedHttpError instead") super.onLoadHttpError, + super.onReceivedHttpError, + super.onProgressChanged, + super.onConsoleMessage, + super.shouldOverrideUrlLoading, + super.onLoadResource, + super.onScrollChanged, + @Deprecated('Use onDownloadStartRequest instead') super.onDownloadStart, + super.onDownloadStartRequest, + @Deprecated('Use onLoadResourceWithCustomScheme instead') + super.onLoadResourceCustomScheme, + super.onLoadResourceWithCustomScheme, + super.onCreateWindow, + super.onCloseWindow, + super.onJsAlert, + super.onJsConfirm, + super.onJsPrompt, + super.onReceivedHttpAuthRequest, + super.onReceivedServerTrustAuthRequest, + super.onReceivedClientCertRequest, + @Deprecated('Use FindInteractionController.onFindResultReceived instead') + super.onFindResultReceived, + super.shouldInterceptAjaxRequest, + super.onAjaxReadyStateChange, + super.onAjaxProgress, + super.shouldInterceptFetchRequest, + super.onUpdateVisitedHistory, + @Deprecated("Use onPrintRequest instead") super.onPrint, + super.onPrintRequest, + super.onLongPressHitTestResult, + super.onEnterFullscreen, + super.onExitFullscreen, + super.onPageCommitVisible, + super.onTitleChanged, + super.onWindowFocus, + super.onWindowBlur, + super.onOverScrolled, + super.onZoomScaleChanged, + @Deprecated('Use onSafeBrowsingHit instead') + super.androidOnSafeBrowsingHit, + super.onSafeBrowsingHit, + @Deprecated('Use onPermissionRequest instead') + super.androidOnPermissionRequest, + super.onPermissionRequest, + @Deprecated('Use onGeolocationPermissionsShowPrompt instead') + super.androidOnGeolocationPermissionsShowPrompt, + super.onGeolocationPermissionsShowPrompt, + @Deprecated('Use onGeolocationPermissionsHidePrompt instead') + super.androidOnGeolocationPermissionsHidePrompt, + super.onGeolocationPermissionsHidePrompt, + @Deprecated('Use shouldInterceptRequest instead') + super.androidShouldInterceptRequest, + super.shouldInterceptRequest, + @Deprecated('Use onRenderProcessGone instead') + super.androidOnRenderProcessGone, + super.onRenderProcessGone, + @Deprecated('Use onRenderProcessResponsive instead') + super.androidOnRenderProcessResponsive, + super.onRenderProcessResponsive, + @Deprecated('Use onRenderProcessUnresponsive instead') + super.androidOnRenderProcessUnresponsive, + super.onRenderProcessUnresponsive, + @Deprecated('Use onFormResubmission instead') + super.androidOnFormResubmission, + super.onFormResubmission, + @Deprecated('Use onZoomScaleChanged instead') super.androidOnScaleChanged, + @Deprecated('Use onReceivedIcon instead') super.androidOnReceivedIcon, + super.onReceivedIcon, + @Deprecated('Use onReceivedTouchIconUrl instead') + super.androidOnReceivedTouchIconUrl, + super.onReceivedTouchIconUrl, + @Deprecated('Use onJsBeforeUnload instead') super.androidOnJsBeforeUnload, + super.onJsBeforeUnload, + @Deprecated('Use onReceivedLoginRequest instead') + super.androidOnReceivedLoginRequest, + super.onReceivedLoginRequest, + super.onPermissionRequestCanceled, + super.onRequestFocus, + @Deprecated('Use onWebContentProcessDidTerminate instead') + super.iosOnWebContentProcessDidTerminate, + super.onWebContentProcessDidTerminate, + @Deprecated( + 'Use onDidReceiveServerRedirectForProvisionalNavigation instead') + super.iosOnDidReceiveServerRedirectForProvisionalNavigation, + super.onDidReceiveServerRedirectForProvisionalNavigation, + @Deprecated('Use onNavigationResponse instead') + super.iosOnNavigationResponse, + super.onNavigationResponse, + @Deprecated('Use shouldAllowDeprecatedTLS instead') + super.iosShouldAllowDeprecatedTLS, + super.shouldAllowDeprecatedTLS, + super.onCameraCaptureStateChanged, + super.onMicrophoneCaptureStateChanged, + super.onContentSizeChanged, + super.initialUrlRequest, + super.initialFile, + super.initialData, + @Deprecated('Use initialSettings instead') super.initialOptions, + super.initialSettings, + super.contextMenu, + super.initialUserScripts, + super.pullToRefreshController, + super.findInteractionController}); /// Controls how one widget replaces another widget in the tree. /// @@ -184,19 +186,18 @@ class PlatformInAppWebViewWidgetCreationParams /// Interface for a platform implementation of a web view widget. abstract class PlatformInAppWebViewWidget extends PlatformInterface implements Disposable { - /// Creates a new [PlatformInAppWebViewWidget] factory PlatformInAppWebViewWidget( PlatformInAppWebViewWidgetCreationParams params) { assert( - InAppWebViewPlatform.instance != null, - 'A platform implementation for `flutter_inappwebview` has not been set. Please ' - 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' - '`InAppWebViewPlatform.instance` before use. For unit testing, ' - '`InAppWebViewPlatform.instance` can be set with your own test implementation.', + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`InAppWebViewPlatform.instance` before use. For unit testing, ' + '`InAppWebViewPlatform.instance` can be set with your own test implementation.', ); final PlatformInAppWebViewWidget webViewWidgetDelegate = - InAppWebViewPlatform.instance!.createPlatformInAppWebViewWidget(params); + InAppWebViewPlatform.instance!.createPlatformInAppWebViewWidget(params); PlatformInterface.verify(webViewWidgetDelegate, _token); return webViewWidgetDelegate; } @@ -219,6 +220,8 @@ abstract class PlatformInAppWebViewWidget extends PlatformInterface /// Returns a Widget tree that embeds the created web view. Widget build(BuildContext context); + T controllerFromPlatform(PlatformInAppWebViewController controller); + @override void dispose(); } diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.dart index 44e397a2..441a2a41 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.dart @@ -16,7 +16,9 @@ import '../print_job/main.dart'; ///{@template flutter_inappwebview.WebView} ///Class that represents a WebView. Used by [InAppWebView], [HeadlessInAppWebView] and the WebView of [PlatformInAppBrowser]. ///{@endtemplate} -class PlatformWebViewCreationParams { +class PlatformWebViewCreationParams { + final T Function(PlatformInAppWebViewController controller)? controllerFromPlatform; + ///{@template flutter_inappwebview.WebView.windowId} ///The window id of a [CreateWindowAction.windowId]. /// @@ -36,7 +38,7 @@ class PlatformWebViewCreationParams { ///- MacOS ///- Web ///{@endtemplate} - final void Function(PlatformInAppWebViewController controller)? onWebViewCreated; + final void Function(T controller)? onWebViewCreated; ///{@template flutter_inappwebview.WebView.onLoadStart} ///Event fired when the `WebView` starts to load an [url]. @@ -52,7 +54,7 @@ class PlatformWebViewCreationParams { ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview)) ///- Web ///{@endtemplate} - final void Function(PlatformInAppWebViewController controller, WebUri? url)? + final void Function(T controller, WebUri? url)? onLoadStart; ///{@template flutter_inappwebview.WebView.onLoadStop} @@ -67,12 +69,12 @@ class PlatformWebViewCreationParams { ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview)) ///- Web ([Official API - Window.onload](https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event)) ///{@endtemplate} - final void Function(PlatformInAppWebViewController controller, WebUri? url)? + final void Function(T controller, WebUri? url)? onLoadStop; ///Use [onReceivedError] instead. @Deprecated("Use onReceivedError instead") - final void Function(PlatformInAppWebViewController controller, Uri? url, int code, + final void Function(T controller, Uri? url, int code, String message)? onLoadError; ///{@template flutter_inappwebview.WebView.onReceivedError} @@ -83,12 +85,12 @@ class PlatformWebViewCreationParams { ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455623-webview)) ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455623-webview)) ///{@endtemplate} - final void Function(PlatformInAppWebViewController controller, + final void Function(T controller, WebResourceRequest request, WebResourceError error)? onReceivedError; ///Use [onReceivedHttpError] instead. @Deprecated("Use onReceivedHttpError instead") - final void Function(PlatformInAppWebViewController controller, Uri? url, + final void Function(T controller, Uri? url, int statusCode, String description)? onLoadHttpError; ///{@template flutter_inappwebview.WebView.onReceivedHttpError} @@ -106,7 +108,7 @@ class PlatformWebViewCreationParams { ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview)) ///{@endtemplate} final void Function( - PlatformInAppWebViewController controller, + T controller, WebResourceRequest request, WebResourceResponse errorResponse)? onReceivedHttpError; @@ -118,7 +120,7 @@ class PlatformWebViewCreationParams { ///- iOS ///- MacOS ///{@endtemplate} - final void Function(PlatformInAppWebViewController controller, int progress)? + final void Function(T controller, int progress)? onProgressChanged; ///{@template flutter_inappwebview.WebView.onConsoleMessage} @@ -133,7 +135,7 @@ class PlatformWebViewCreationParams { ///- Web ///{@endtemplate} final void Function( - PlatformInAppWebViewController controller, ConsoleMessage consoleMessage)? + T controller, ConsoleMessage consoleMessage)? onConsoleMessage; ///{@template flutter_inappwebview.WebView.shouldOverrideUrlLoading} @@ -156,7 +158,7 @@ class PlatformWebViewCreationParams { ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455641-webview)) ///{@endtemplate} final Future Function( - PlatformInAppWebViewController controller, NavigationAction navigationAction)? + T controller, NavigationAction navigationAction)? shouldOverrideUrlLoading; ///{@template flutter_inappwebview.WebView.onLoadResource} @@ -170,7 +172,7 @@ class PlatformWebViewCreationParams { ///- MacOS ///{@endtemplate} final void Function( - PlatformInAppWebViewController controller, LoadedResource resource)? + T controller, LoadedResource resource)? onLoadResource; ///{@template flutter_inappwebview.WebView.onScrollChanged} @@ -190,12 +192,12 @@ class PlatformWebViewCreationParams { ///- Web ([Official API - Window.onscroll](https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onscroll)) ///- MacOS ///{@endtemplate} - final void Function(PlatformInAppWebViewController controller, int x, int y)? + final void Function(T controller, int x, int y)? onScrollChanged; ///Use [onDownloadStartRequest] instead @Deprecated('Use onDownloadStartRequest instead') - final void Function(PlatformInAppWebViewController controller, Uri url)? + final void Function(T controller, Uri url)? onDownloadStart; ///{@template flutter_inappwebview.WebView.onDownloadStartRequest} @@ -211,13 +213,13 @@ class PlatformWebViewCreationParams { ///- iOS ///- MacOS ///{@endtemplate} - final void Function(PlatformInAppWebViewController controller, + final void Function(T controller, DownloadStartRequest downloadStartRequest)? onDownloadStartRequest; ///Use [onLoadResourceWithCustomScheme] instead. @Deprecated('Use onLoadResourceWithCustomScheme instead') final Future Function( - PlatformInAppWebViewController controller, Uri url)? onLoadResourceCustomScheme; + T controller, Uri url)? onLoadResourceCustomScheme; ///{@template flutter_inappwebview.WebView.onLoadResourceWithCustomScheme} ///Event fired when the `WebView` finds the `custom-scheme` while loading a resource. @@ -229,7 +231,7 @@ class PlatformWebViewCreationParams { ///- MacOS ([Official API - WKURLSchemeHandler](https://developer.apple.com/documentation/webkit/wkurlschemehandler)) ///{@endtemplate} final Future Function( - PlatformInAppWebViewController controller, WebResourceRequest request)? + T controller, WebResourceRequest request)? onLoadResourceWithCustomScheme; ///{@template flutter_inappwebview.WebView.onCreateWindow} @@ -271,7 +273,7 @@ class PlatformWebViewCreationParams { ///- MacOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview)) ///- Web ///{@endtemplate} - final Future Function(PlatformInAppWebViewController controller, + final Future Function(T controller, CreateWindowAction createWindowAction)? onCreateWindow; ///{@template flutter_inappwebview.WebView.onCloseWindow} @@ -283,7 +285,7 @@ class PlatformWebViewCreationParams { ///- iOS ([Official API - WKUIDelegate.webViewDidClose](https://developer.apple.com/documentation/webkit/wkuidelegate/1537390-webviewdidclose)) ///- MacOS ([Official API - WKUIDelegate.webViewDidClose](https://developer.apple.com/documentation/webkit/wkuidelegate/1537390-webviewdidclose)) ///{@endtemplate} - final void Function(PlatformInAppWebViewController controller)? onCloseWindow; + final void Function(T controller)? onCloseWindow; ///{@template flutter_inappwebview.WebView.onWindowFocus} ///Event fired when the JavaScript `window` object of the WebView has received focus. @@ -297,7 +299,7 @@ class PlatformWebViewCreationParams { ///- MacOS ///- Web ([Official API - Window.onfocus](https://developer.mozilla.org/en-US/docs/Web/API/Window/focus_event)) ///{@endtemplate} - final void Function(PlatformInAppWebViewController controller)? onWindowFocus; + final void Function(T controller)? onWindowFocus; ///{@template flutter_inappwebview.WebView.onWindowBlur} ///Event fired when the JavaScript `window` object of the WebView has lost focus. @@ -311,7 +313,7 @@ class PlatformWebViewCreationParams { ///- MacOS ///- Web ([Official API - Window.onblur](https://developer.mozilla.org/en-US/docs/Web/API/Window/blur_event)) ///{@endtemplate} - final void Function(PlatformInAppWebViewController controller)? onWindowBlur; + final void Function(T controller)? onWindowBlur; ///{@template flutter_inappwebview.WebView.onJsAlert} ///Event fired when javascript calls the `alert()` method to display an alert dialog. @@ -325,7 +327,7 @@ class PlatformWebViewCreationParams { ///- MacOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1537406-webview)) ///{@endtemplate} final Future Function( - PlatformInAppWebViewController controller, JsAlertRequest jsAlertRequest)? + T controller, JsAlertRequest jsAlertRequest)? onJsAlert; ///{@template flutter_inappwebview.WebView.onJsConfirm} @@ -340,7 +342,7 @@ class PlatformWebViewCreationParams { ///- MacOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1536489-webview)) ///{@endtemplate} final Future Function( - PlatformInAppWebViewController controller, JsConfirmRequest jsConfirmRequest)? + T controller, JsConfirmRequest jsConfirmRequest)? onJsConfirm; ///{@template flutter_inappwebview.WebView.onJsPrompt} @@ -355,7 +357,7 @@ class PlatformWebViewCreationParams { ///- MacOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1538086-webview)) ///{@endtemplate} final Future Function( - PlatformInAppWebViewController controller, JsPromptRequest jsPromptRequest)? + T controller, JsPromptRequest jsPromptRequest)? onJsPrompt; ///{@template flutter_inappwebview.WebView.onReceivedHttpAuthRequest} @@ -368,7 +370,7 @@ class PlatformWebViewCreationParams { ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview)) ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview)) ///{@endtemplate} - final Future Function(PlatformInAppWebViewController controller, + final Future Function(T controller, HttpAuthenticationChallenge challenge)? onReceivedHttpAuthRequest; ///{@template flutter_inappwebview.WebView.onReceivedServerTrustAuthRequest} @@ -383,7 +385,7 @@ class PlatformWebViewCreationParams { ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview)) ///{@endtemplate} final Future Function( - PlatformInAppWebViewController controller, ServerTrustChallenge challenge)? + T controller, ServerTrustChallenge challenge)? onReceivedServerTrustAuthRequest; ///{@template flutter_inappwebview.WebView.onReceivedClientCertRequest} @@ -400,12 +402,12 @@ class PlatformWebViewCreationParams { ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview)) ///{@endtemplate} final Future Function( - PlatformInAppWebViewController controller, ClientCertChallenge challenge)? + T controller, ClientCertChallenge challenge)? onReceivedClientCertRequest; ///Use [FindInteractionController.onFindResultReceived] instead. @Deprecated('Use FindInteractionController.onFindResultReceived instead') - final void Function(PlatformInAppWebViewController controller, int activeMatchOrdinal, + final void Function(T controller, int activeMatchOrdinal, int numberOfMatches, bool isDoneCounting)? onFindResultReceived; ///{@template flutter_inappwebview.WebView.shouldInterceptAjaxRequest} @@ -426,7 +428,7 @@ class PlatformWebViewCreationParams { ///- MacOS ///{@endtemplate} final Future Function( - PlatformInAppWebViewController controller, AjaxRequest ajaxRequest)? + T controller, AjaxRequest ajaxRequest)? shouldInterceptAjaxRequest; ///{@template flutter_inappwebview.WebView.onAjaxReadyStateChange} @@ -447,7 +449,7 @@ class PlatformWebViewCreationParams { ///- MacOS ///{@endtemplate} final Future Function( - PlatformInAppWebViewController controller, AjaxRequest ajaxRequest)? + T controller, AjaxRequest ajaxRequest)? onAjaxReadyStateChange; ///{@template flutter_inappwebview.WebView.onAjaxProgress} @@ -468,7 +470,7 @@ class PlatformWebViewCreationParams { ///- MacOS ///{@endtemplate} final Future Function( - PlatformInAppWebViewController controller, AjaxRequest ajaxRequest)? + T controller, AjaxRequest ajaxRequest)? onAjaxProgress; ///{@template flutter_inappwebview.WebView.shouldInterceptFetchRequest} @@ -489,7 +491,7 @@ class PlatformWebViewCreationParams { ///- MacOS ///{@endtemplate} final Future Function( - PlatformInAppWebViewController controller, FetchRequest fetchRequest)? + T controller, FetchRequest fetchRequest)? shouldInterceptFetchRequest; ///{@template flutter_inappwebview.WebView.onUpdateVisitedHistory} @@ -511,12 +513,12 @@ class PlatformWebViewCreationParams { ///- Web ///{@endtemplate} final void Function( - PlatformInAppWebViewController controller, WebUri? url, bool? isReload)? + T controller, WebUri? url, bool? isReload)? onUpdateVisitedHistory; ///Use [onPrintRequest] instead @Deprecated("Use onPrintRequest instead") - final void Function(PlatformInAppWebViewController controller, Uri? url)? onPrint; + final void Function(T controller, Uri? url)? onPrint; ///{@template flutter_inappwebview.WebView.onPrintRequest} ///Event fired when `window.print()` is called from JavaScript side. @@ -536,7 +538,7 @@ class PlatformWebViewCreationParams { ///- MacOS ///- Web ///{@endtemplate} - final Future Function(PlatformInAppWebViewController controller, WebUri? url, + final Future Function(T controller, WebUri? url, PlatformPrintJobController? printJobController)? onPrintRequest; ///{@template flutter_inappwebview.WebView.onLongPressHitTestResult} @@ -548,7 +550,7 @@ class PlatformWebViewCreationParams { ///- Android native WebView ([Official API - View.setOnLongClickListener](https://developer.android.com/reference/android/view/View#setOnLongClickListener(android.view.View.OnLongClickListener))) ///- iOS ([Official API - UILongPressGestureRecognizer](https://developer.apple.com/documentation/uikit/uilongpressgesturerecognizer)) ///{@endtemplate} - final void Function(PlatformInAppWebViewController controller, + final void Function(T controller, InAppWebViewHitTestResult hitTestResult)? onLongPressHitTestResult; ///{@template flutter_inappwebview.WebView.onEnterFullscreen} @@ -560,7 +562,7 @@ class PlatformWebViewCreationParams { ///- MacOS ([Official API - NSWindow.didEnterFullScreenNotification](https://developer.apple.com/documentation/appkit/nswindow/1419651-didenterfullscreennotification)) ///- Web ([Official API - Document.onfullscreenchange](https://developer.mozilla.org/en-US/docs/Web/API/Document/fullscreenchange_event)) ///{@endtemplate} - final void Function(PlatformInAppWebViewController controller)? onEnterFullscreen; + final void Function(T controller)? onEnterFullscreen; ///{@template flutter_inappwebview.WebView.onExitFullscreen} ///Event fired when the current page has exited full screen mode. @@ -575,7 +577,7 @@ class PlatformWebViewCreationParams { ///- MacOS ([Official API - NSWindow.didExitFullScreenNotification](https://developer.apple.com/documentation/appkit/nswindow/1419177-didexitfullscreennotification)) ///- Web ([Official API - Document.onfullscreenchange](https://developer.mozilla.org/en-US/docs/Web/API/Document/fullscreenchange_event)) ///{@endtemplate} - final void Function(PlatformInAppWebViewController controller)? onExitFullscreen; + final void Function(T controller)? onExitFullscreen; ///{@template flutter_inappwebview.WebView.onPageCommitVisible} ///Called when the web view begins to receive web content. @@ -590,7 +592,7 @@ class PlatformWebViewCreationParams { ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview)) ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview)) ///{@endtemplate} - final void Function(PlatformInAppWebViewController controller, WebUri? url)? + final void Function(T controller, WebUri? url)? onPageCommitVisible; ///{@template flutter_inappwebview.WebView.onTitleChanged} @@ -606,7 +608,7 @@ class PlatformWebViewCreationParams { ///- MacOS ///- Web ///{@endtemplate} - final void Function(PlatformInAppWebViewController controller, String? title)? + final void Function(T controller, String? title)? onTitleChanged; ///{@template flutter_inappwebview.WebView.onOverScrolled} @@ -624,7 +626,7 @@ class PlatformWebViewCreationParams { ///- Android native WebView ([Official API - WebView.onOverScrolled](https://developer.android.com/reference/android/webkit/WebView#onOverScrolled(int,%20int,%20boolean,%20boolean))) ///- iOS ///{@endtemplate} - final void Function(PlatformInAppWebViewController controller, int x, int y, + final void Function(T controller, int x, int y, bool clampedX, bool clampedY)? onOverScrolled; ///{@template flutter_inappwebview.WebView.onZoomScaleChanged} @@ -642,13 +644,13 @@ class PlatformWebViewCreationParams { ///- Web ///{@endtemplate} final void Function( - PlatformInAppWebViewController controller, double oldScale, double newScale)? + T controller, double oldScale, double newScale)? onZoomScaleChanged; ///Use [onSafeBrowsingHit] instead. @Deprecated("Use onSafeBrowsingHit instead") final Future Function( - PlatformInAppWebViewController controller, + T controller, Uri url, SafeBrowsingThreat? threatType)? androidOnSafeBrowsingHit; @@ -666,14 +668,14 @@ class PlatformWebViewCreationParams { ///- Android native WebView ([Official API - WebViewClient.onSafeBrowsingHit](https://developer.android.com/reference/android/webkit/WebViewClient#onSafeBrowsingHit(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20int,%20android.webkit.SafeBrowsingResponse))) ///{@endtemplate} final Future Function( - PlatformInAppWebViewController controller, + T controller, WebUri url, SafeBrowsingThreat? threatType)? onSafeBrowsingHit; ///Use [onPermissionRequest] instead. @Deprecated("Use onPermissionRequest instead") final Future Function( - PlatformInAppWebViewController controller, + T controller, String origin, List resources)? androidOnPermissionRequest; @@ -694,13 +696,13 @@ class PlatformWebViewCreationParams { ///- iOS ///- MacOS ///{@endtemplate} - final Future Function(PlatformInAppWebViewController controller, + final Future Function(T controller, PermissionRequest permissionRequest)? onPermissionRequest; ///Use [onGeolocationPermissionsShowPrompt] instead. @Deprecated("Use onGeolocationPermissionsShowPrompt instead") final Future Function( - PlatformInAppWebViewController controller, String origin)? + T controller, String origin)? androidOnGeolocationPermissionsShowPrompt; ///{@template flutter_inappwebview.WebView.onGeolocationPermissionsShowPrompt} @@ -714,12 +716,12 @@ class PlatformWebViewCreationParams { ///- Android native WebView ([Official API - WebChromeClient.onGeolocationPermissionsShowPrompt](https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsShowPrompt(java.lang.String,%20android.webkit.GeolocationPermissions.Callback))) ///{@endtemplate} final Future Function( - PlatformInAppWebViewController controller, String origin)? + T controller, String origin)? onGeolocationPermissionsShowPrompt; ///Use [onGeolocationPermissionsHidePrompt] instead. @Deprecated("Use onGeolocationPermissionsHidePrompt instead") - final void Function(PlatformInAppWebViewController controller)? + final void Function(T controller)? androidOnGeolocationPermissionsHidePrompt; ///{@template flutter_inappwebview.WebView.onGeolocationPermissionsHidePrompt} @@ -729,13 +731,13 @@ class PlatformWebViewCreationParams { ///**Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebChromeClient.onGeolocationPermissionsHidePrompt](https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsHidePrompt())) ///{@endtemplate} - final void Function(PlatformInAppWebViewController controller)? + final void Function(T controller)? onGeolocationPermissionsHidePrompt; ///Use [shouldInterceptRequest] instead. @Deprecated("Use shouldInterceptRequest instead") final Future Function( - PlatformInAppWebViewController controller, WebResourceRequest request)? + T controller, WebResourceRequest request)? androidShouldInterceptRequest; ///{@template flutter_inappwebview.WebView.shouldInterceptRequest} @@ -757,13 +759,13 @@ class PlatformWebViewCreationParams { ///- Android native WebView ([Official API - WebViewClient.shouldInterceptRequest](https://developer.android.com/reference/android/webkit/WebViewClient#shouldInterceptRequest(android.webkit.WebView,%20android.webkit.WebResourceRequest))) ///{@endtemplate} final Future Function( - PlatformInAppWebViewController controller, WebResourceRequest request)? + T controller, WebResourceRequest request)? shouldInterceptRequest; ///Use [onRenderProcessUnresponsive] instead. @Deprecated("Use onRenderProcessUnresponsive instead") final Future Function( - PlatformInAppWebViewController controller, Uri? url)? + T controller, Uri? url)? androidOnRenderProcessUnresponsive; ///{@template flutter_inappwebview.WebView.onRenderProcessUnresponsive} @@ -788,13 +790,13 @@ class PlatformWebViewCreationParams { ///- Android native WebView ([Official API - WebViewRenderProcessClient.onRenderProcessUnresponsive](https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessUnresponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess))) ///{@endtemplate} final Future Function( - PlatformInAppWebViewController controller, WebUri? url)? + T controller, WebUri? url)? onRenderProcessUnresponsive; ///Use [onRenderProcessResponsive] instead. @Deprecated("Use onRenderProcessResponsive instead") final Future Function( - PlatformInAppWebViewController controller, Uri? url)? + T controller, Uri? url)? androidOnRenderProcessResponsive; ///{@template flutter_inappwebview.WebView.onRenderProcessResponsive} @@ -812,13 +814,13 @@ class PlatformWebViewCreationParams { ///- Android native WebView ([Official API - WebViewRenderProcessClient.onRenderProcessResponsive](https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessResponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess))) ///{@endtemplate} final Future Function( - PlatformInAppWebViewController controller, WebUri? url)? + T controller, WebUri? url)? onRenderProcessResponsive; ///Use [onRenderProcessGone] instead. @Deprecated("Use onRenderProcessGone instead") final void Function( - PlatformInAppWebViewController controller, RenderProcessGoneDetail detail)? + T controller, RenderProcessGoneDetail detail)? androidOnRenderProcessGone; ///{@template flutter_inappwebview.WebView.onRenderProcessGone} @@ -834,13 +836,13 @@ class PlatformWebViewCreationParams { ///- Android native WebView ([Official API - WebViewClient.onRenderProcessGone](https://developer.android.com/reference/android/webkit/WebViewClient#onRenderProcessGone(android.webkit.WebView,%20android.webkit.RenderProcessGoneDetail))) ///{@endtemplate} final void Function( - PlatformInAppWebViewController controller, RenderProcessGoneDetail detail)? + T controller, RenderProcessGoneDetail detail)? onRenderProcessGone; ///Use [onFormResubmission] instead. @Deprecated('Use onFormResubmission instead') final Future Function( - PlatformInAppWebViewController controller, Uri? url)? androidOnFormResubmission; + T controller, Uri? url)? androidOnFormResubmission; ///{@template flutter_inappwebview.WebView.onFormResubmission} ///As the host application if the browser should resend data as the requested page was a result of a POST. The default is to not resend the data. @@ -849,17 +851,17 @@ class PlatformWebViewCreationParams { ///- Android native WebView ([Official API - WebViewClient.onFormResubmission](https://developer.android.com/reference/android/webkit/WebViewClient#onFormResubmission(android.webkit.WebView,%20android.os.Message,%20android.os.Message))) ///{@endtemplate} final Future Function( - PlatformInAppWebViewController controller, WebUri? url)? onFormResubmission; + T controller, WebUri? url)? onFormResubmission; ///Use [onZoomScaleChanged] instead. @Deprecated('Use onZoomScaleChanged instead') final void Function( - PlatformInAppWebViewController controller, double oldScale, double newScale)? + T controller, double oldScale, double newScale)? androidOnScaleChanged; ///Use [onReceivedIcon] instead. @Deprecated('Use onReceivedIcon instead') - final void Function(PlatformInAppWebViewController controller, Uint8List icon)? + final void Function(T controller, Uint8List icon)? androidOnReceivedIcon; ///{@template flutter_inappwebview.WebView.onReceivedIcon} @@ -870,13 +872,13 @@ class PlatformWebViewCreationParams { ///**Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebChromeClient.onReceivedIcon](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedIcon(android.webkit.WebView,%20android.graphics.Bitmap))) ///{@endtemplate} - final void Function(PlatformInAppWebViewController controller, Uint8List icon)? + final void Function(T controller, Uint8List icon)? onReceivedIcon; ///Use [onReceivedTouchIconUrl] instead. @Deprecated('Use onReceivedTouchIconUrl instead') final void Function( - PlatformInAppWebViewController controller, Uri url, bool precomposed)? + T controller, Uri url, bool precomposed)? androidOnReceivedTouchIconUrl; ///{@template flutter_inappwebview.WebView.onReceivedTouchIconUrl} @@ -890,13 +892,13 @@ class PlatformWebViewCreationParams { ///- Android native WebView ([Official API - WebChromeClient.onReceivedTouchIconUrl](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTouchIconUrl(android.webkit.WebView,%20java.lang.String,%20boolean))) ///{@endtemplate} final void Function( - PlatformInAppWebViewController controller, WebUri url, bool precomposed)? + T controller, WebUri url, bool precomposed)? onReceivedTouchIconUrl; ///Use [onJsBeforeUnload] instead. @Deprecated('Use onJsBeforeUnload instead') final Future Function( - PlatformInAppWebViewController controller, + T controller, JsBeforeUnloadRequest jsBeforeUnloadRequest)? androidOnJsBeforeUnload; ///{@template flutter_inappwebview.WebView.onJsBeforeUnload} @@ -914,13 +916,13 @@ class PlatformWebViewCreationParams { ///- Android native WebView ([Official API - WebChromeClient.onJsBeforeUnload](https://developer.android.com/reference/android/webkit/WebChromeClient#onJsBeforeUnload(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult))) ///{@endtemplate} final Future Function( - PlatformInAppWebViewController controller, + T controller, JsBeforeUnloadRequest jsBeforeUnloadRequest)? onJsBeforeUnload; ///Use [onReceivedLoginRequest] instead. @Deprecated('Use onReceivedLoginRequest instead') final void Function( - PlatformInAppWebViewController controller, LoginRequest loginRequest)? + T controller, LoginRequest loginRequest)? androidOnReceivedLoginRequest; ///{@template flutter_inappwebview.WebView.onReceivedLoginRequest} @@ -932,7 +934,7 @@ class PlatformWebViewCreationParams { ///- Android native WebView ([Official API - WebViewClient.onReceivedLoginRequest](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedLoginRequest(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20java.lang.String))) ///{@endtemplate} final void Function( - PlatformInAppWebViewController controller, LoginRequest loginRequest)? + T controller, LoginRequest loginRequest)? onReceivedLoginRequest; ///{@template flutter_inappwebview.WebView.onPermissionRequestCanceled} @@ -947,7 +949,7 @@ class PlatformWebViewCreationParams { ///**Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebChromeClient.onPermissionRequestCanceled](https://developer.android.com/reference/android/webkit/WebChromeClient#onPermissionRequestCanceled(android.webkit.PermissionRequest))) ///{@endtemplate} - final void Function(PlatformInAppWebViewController controller, + final void Function(T controller, PermissionRequest permissionRequest)? onPermissionRequestCanceled; ///{@template flutter_inappwebview.WebView.onRequestFocus} @@ -957,11 +959,11 @@ class PlatformWebViewCreationParams { ///**Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebChromeClient.onRequestFocus](https://developer.android.com/reference/android/webkit/WebChromeClient#onRequestFocus(android.webkit.WebView))) ///{@endtemplate} - final void Function(PlatformInAppWebViewController controller)? onRequestFocus; + final void Function(T controller)? onRequestFocus; ///Use [onWebContentProcessDidTerminate] instead. @Deprecated('Use onWebContentProcessDidTerminate instead') - final void Function(PlatformInAppWebViewController controller)? + final void Function(T controller)? iosOnWebContentProcessDidTerminate; ///{@template flutter_inappwebview.WebView.onWebContentProcessDidTerminate} @@ -971,12 +973,12 @@ class PlatformWebViewCreationParams { ///- iOS ([Official API - WKNavigationDelegate.webViewWebContentProcessDidTerminate](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455639-webviewwebcontentprocessdidtermi)) ///- MacOS ([Official API - WKNavigationDelegate.webViewWebContentProcessDidTerminate](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455639-webviewwebcontentprocessdidtermi)) ///{@endtemplate} - final void Function(PlatformInAppWebViewController controller)? + final void Function(T controller)? onWebContentProcessDidTerminate; ///Use [onDidReceiveServerRedirectForProvisionalNavigation] instead. @Deprecated('Use onDidReceiveServerRedirectForProvisionalNavigation instead') - final void Function(PlatformInAppWebViewController controller)? + final void Function(T controller)? iosOnDidReceiveServerRedirectForProvisionalNavigation; ///{@template flutter_inappwebview.WebView.onDidReceiveServerRedirectForProvisionalNavigation} @@ -986,13 +988,13 @@ class PlatformWebViewCreationParams { ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455627-webview)) ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455627-webview)) ///{@endtemplate} - final void Function(PlatformInAppWebViewController controller)? + final void Function(T controller)? onDidReceiveServerRedirectForProvisionalNavigation; ///Use [onNavigationResponse] instead. @Deprecated('Use onNavigationResponse instead') final Future Function( - PlatformInAppWebViewController controller, + T controller, IOSWKNavigationResponse navigationResponse)? iosOnNavigationResponse; ///{@template flutter_inappwebview.WebView.onNavigationResponse} @@ -1007,13 +1009,13 @@ class PlatformWebViewCreationParams { ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview)) ///{@endtemplate} final Future Function( - PlatformInAppWebViewController controller, + T controller, NavigationResponse navigationResponse)? onNavigationResponse; ///Use [shouldAllowDeprecatedTLS] instead. @Deprecated('Use shouldAllowDeprecatedTLS instead') final Future Function( - PlatformInAppWebViewController controller, + T controller, URLAuthenticationChallenge challenge)? iosShouldAllowDeprecatedTLS; ///{@template flutter_inappwebview.WebView.shouldAllowDeprecatedTLS} @@ -1030,7 +1032,7 @@ class PlatformWebViewCreationParams { ///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/3601237-webview)) ///{@endtemplate} final Future Function( - PlatformInAppWebViewController controller, + T controller, URLAuthenticationChallenge challenge)? shouldAllowDeprecatedTLS; ///{@template flutter_inappwebview.WebView.onCameraCaptureStateChanged} @@ -1045,7 +1047,7 @@ class PlatformWebViewCreationParams { ///- MacOS ///{@endtemplate} final Future Function( - PlatformInAppWebViewController controller, + T controller, MediaCaptureState? oldState, MediaCaptureState? newState, )? onCameraCaptureStateChanged; @@ -1062,7 +1064,7 @@ class PlatformWebViewCreationParams { ///- MacOS ///{@endtemplate} final Future Function( - PlatformInAppWebViewController controller, + T controller, MediaCaptureState? oldState, MediaCaptureState? newState, )? onMicrophoneCaptureStateChanged; @@ -1077,7 +1079,7 @@ class PlatformWebViewCreationParams { ///**Supported Platforms/Implementations**: ///- iOS ///{@endtemplate} - final void Function(PlatformInAppWebViewController controller, Size oldContentSize, + final void Function(T controller, Size oldContentSize, Size newContentSize)? onContentSizeChanged; ///{@template flutter_inappwebview.WebView.initialUrlRequest} @@ -1178,7 +1180,8 @@ class PlatformWebViewCreationParams { ///{@macro flutter_inappwebview.WebView} const PlatformWebViewCreationParams( - {this.windowId, + {this.controllerFromPlatform, + this.windowId, this.onWebViewCreated, this.onLoadStart, this.onLoadStop, diff --git a/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart b/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart index d4fa05e8..7afddc8c 100644 --- a/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart @@ -1,5 +1,6 @@ import 'package:plugin_platform_interface/plugin_platform_interface.dart'; +import 'chrome_safari_browser/platform_chrome_safari_browser.dart'; import 'find_interaction/platform_find_interaction_controller.dart'; import 'in_app_browser/platform_in_app_browser.dart'; import 'in_app_webview/platform_headless_in_app_webview.dart'; @@ -348,26 +349,6 @@ abstract class InAppWebViewPlatform extends PlatformInterface { 'createPlatformTracingController is not implemented on the current platform.'); } - /// Creates a new [PlatformWebViewAssetLoader]. - /// - /// This function should only be called by the app-facing package. - /// Look at using [WebViewAssetLoader] in `flutter_inappwebview` instead. - PlatformWebViewAssetLoader createPlatformWebViewAssetLoader( - PlatformWebViewAssetLoaderCreationParams params, - ) { - throw UnimplementedError( - 'createPlatformWebViewAssetLoader is not implemented on the current platform.'); - } - - /// Creates a new empty [PlatformWebViewAssetLoader] to access static methods. - /// - /// This function should only be called by the app-facing package. - /// Look at using [WebViewAssetLoader] in `flutter_inappwebview` instead. - PlatformWebViewAssetLoader createPlatformWebViewAssetLoaderStatic() { - throw UnimplementedError( - 'createPlatformWebViewAssetLoaderStatic is not implemented on the current platform.'); - } - /// Creates a new [PlatformPathHandler]. /// /// This function should only be called by the app-facing package. @@ -440,4 +421,24 @@ abstract class InAppWebViewPlatform extends PlatformInterface { PlatformInAppLocalhostServerCreationParams params) { return DefaultInAppLocalhostServer(params); } + + /// Creates a new [PlatformChromeSafariBrowser]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ChromeSafariBrowser] in `flutter_inappwebview` instead. + PlatformChromeSafariBrowser createPlatformChromeSafariBrowser( + PlatformChromeSafariBrowserCreationParams params, + ) { + throw UnimplementedError( + 'createPlatformChromeSafariBrowser is not implemented on the current platform.'); + } + + /// Creates a new empty [PlatformChromeSafariBrowser] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ChromeSafariBrowser] in `flutter_inappwebview` instead. + PlatformChromeSafariBrowser createPlatformChromeSafariBrowserStatic() { + throw UnimplementedError( + 'createPlatformChromeSafariBrowserStatic is not implemented on the current platform.'); + } } diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_webview_asset_loader.dart b/flutter_inappwebview_platform_interface/lib/src/platform_webview_asset_loader.dart index 08557609..4082cd9d 100644 --- a/flutter_inappwebview_platform_interface/lib/src/platform_webview_asset_loader.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_webview_asset_loader.dart @@ -1,30 +1,13 @@ import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; import 'inappwebview_platform.dart'; import 'types/web_resource_response.dart'; -/// Object specifying creation parameters for creating a [PlatformWebViewAssetLoader]. -/// -/// Platform specific implementations can add additional fields by extending -/// this class. -@immutable -class PlatformWebViewAssetLoaderCreationParams { - /// Used by the platform implementation to create a new [PlatformWebViewAssetLoader]. - const PlatformWebViewAssetLoaderCreationParams( - {this.domain, this.httpAllowed, this.pathHandlers}); +part 'platform_webview_asset_loader.g.dart'; - ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewAssetLoader.domain} - final String? domain; - - ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewAssetLoader.httpAllowed} - final bool? httpAllowed; - - ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewAssetLoader.pathHandlers} - final List? pathHandlers; -} - -///Helper class to load local files including application's static assets and resources using http(s):// URLs inside a `WebView` class. +///Helper class to load local files including application's static assets and resources using http(s):// URLs inside a [WebView] class. ///Loading local files using web-like URLs instead of `file://` is desirable as it is compatible with the Same-Origin policy. /// ///For more context about application's assets and resources and how to normally access them please refer to @@ -36,77 +19,32 @@ class PlatformWebViewAssetLoaderCreationParams { /// ///**Supported Platforms/Implementations**: ///- Android native WebView -abstract class PlatformWebViewAssetLoader extends PlatformInterface { +@ExchangeableObject(copyMethod: true) +class WebViewAssetLoader_ { ///An unused domain reserved for Android applications to intercept requests for app assets. /// ///It is used by default unless the user specified a different domain. static final String DEFAULT_DOMAIN = "appassets.androidplatform.net"; - ///{@template flutter_inappwebview_platform_interface.PlatformWebViewAssetLoader.domain} ///Set the domain under which app assets can be accessed. The default domain is `appassets.androidplatform.net`. - ///{@endtemplate} - String? get domain => params.domain; + String? domain; - ///{@template flutter_inappwebview_platform_interface.PlatformWebViewAssetLoader.httpAllowed} ///Allow using the HTTP scheme in addition to HTTPS. The default is to not allow HTTP. - ///{@endtemplate} - bool? get httpAllowed => params.httpAllowed; + bool? httpAllowed; - ///{@template flutter_inappwebview_platform_interface.PlatformWebViewAssetLoader.pathHandlers} ///List of registered path handlers. /// ///[WebViewAssetLoader] will try Path Handlers in the order they're registered, ///and will use whichever is the first to return a non-null. - ///{@endtemplate} - List? get pathHandlers => params.pathHandlers; + List? pathHandlers; - /// Creates a new [PlatformWebViewAssetLoader] - factory PlatformWebViewAssetLoader( - PlatformWebViewAssetLoaderCreationParams params) { - assert( - InAppWebViewPlatform.instance != null, - 'A platform implementation for `flutter_inappwebview` has not been set. Please ' - 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' - '`WebViewPlatform.instance` before use. For unit testing, ' - '`WebViewPlatform.instance` can be set with your own test implementation.', - ); - final PlatformWebViewAssetLoader webViewAssetLoader = - InAppWebViewPlatform.instance!.createPlatformWebViewAssetLoader(params); - PlatformInterface.verify(webViewAssetLoader, _token); - return webViewAssetLoader; - } + WebViewAssetLoader_({this.domain, this.httpAllowed, this.pathHandlers}); +} - /// Creates a new [PlatformWebViewAssetLoader] to access static methods. - factory PlatformWebViewAssetLoader.static() { - assert( - InAppWebViewPlatform.instance != null, - 'A platform implementation for `flutter_inappwebview` has not been set. Please ' - 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' - '`InAppWebViewPlatform.instance` before use. For unit testing, ' - '`InAppWebViewPlatform.instance` can be set with your own test implementation.', - ); - final PlatformWebViewAssetLoader webViewAssetLoader = - InAppWebViewPlatform.instance!.createPlatformWebViewAssetLoaderStatic(); - PlatformInterface.verify(webViewAssetLoader, _token); - return webViewAssetLoader; - } - - /// Used by the platform implementation to create a new - /// [PlatformWebViewAssetLoader]. - /// - /// Should only be used by platform implementations because they can't extend - /// a class that only contains a factory constructor. - @protected - PlatformWebViewAssetLoader.implementation(this.params) : super(token: _token); - - static final Object _token = Object(); - - /// The parameters used to initialize the [PlatformWebViewAssetLoader]. - final PlatformWebViewAssetLoaderCreationParams params; - - PlatformWebViewAssetLoader? fromMap(Map? map) { +abstract class IPathHandler { + String get path { throw UnimplementedError( - 'fromMap is not implemented on the current platform'); + 'path is not implemented on the current platform'); } Map toMap() { @@ -118,11 +56,6 @@ abstract class PlatformWebViewAssetLoader extends PlatformInterface { throw UnimplementedError( 'toJson is not implemented on the current platform'); } - - PlatformWebViewAssetLoader copy() { - throw UnimplementedError( - 'copy is not implemented on the current platform'); - } } /// Object specifying creation parameters for creating a [PlatformPathHandler]. @@ -141,7 +74,7 @@ class PlatformPathHandlerCreationParams { ///A handler that produces responses for a registered path. /// ///Implement this interface to handle other use-cases according to your app's needs. -abstract class PlatformPathHandler extends PlatformInterface { +abstract class PlatformPathHandler extends PlatformInterface implements IPathHandler { /// Creates a new [PlatformWebViewAssetLoader] factory PlatformPathHandler(PlatformPathHandlerCreationParams params) { assert( @@ -240,7 +173,7 @@ class PlatformAssetsPathHandlerCreationParams ///[guessContentTypeFromName](https://developer.android.com/reference/java/net/URLConnection.html#guessContentTypeFromName-java.lang.String-). ///Developers should ensure that asset files are named using standard file extensions. ///If the file does not have a recognised extension, `text/plain` will be used by default. -class PlatformAssetsPathHandler extends PlatformPathHandler { +abstract class PlatformAssetsPathHandler extends PlatformPathHandler { /// Creates a new [PlatformAssetsPathHandler] factory PlatformAssetsPathHandler( PlatformAssetsPathHandlerCreationParams params) { @@ -308,7 +241,7 @@ class PlatformResourcesPathHandlerCreationParams ///[guessContentTypeFromName](https://developer.android.com/reference/java/net/URLConnection.html#guessContentTypeFromName-java.lang.String-). ///Developers should ensure that asset files are named using standard file extensions. ///If the file does not have a recognised extension, `text/plain` will be used by default. -class PlatformResourcesPathHandler extends PlatformPathHandler { +abstract class PlatformResourcesPathHandler extends PlatformPathHandler { /// Creates a new [PlatformResourcesPathHandler] factory PlatformResourcesPathHandler( PlatformResourcesPathHandlerCreationParams params) { @@ -387,7 +320,7 @@ class PlatformInternalStoragePathHandlerCreationParams ///[guessContentTypeFromName](https://developer.android.com/reference/java/net/URLConnection.html#guessContentTypeFromName-java.lang.String-). ///Developers should ensure that asset files are named using standard file extensions. ///If the file does not have a recognised extension, `text/plain` will be used by default. -class PlatformInternalStoragePathHandler extends PlatformPathHandler { +abstract class PlatformInternalStoragePathHandler extends PlatformPathHandler { /// Creates a new [PlatformResourcesPathHandler] factory PlatformInternalStoragePathHandler( PlatformInternalStoragePathHandlerCreationParams params) { diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_webview_asset_loader.g.dart b/flutter_inappwebview_platform_interface/lib/src/platform_webview_asset_loader.g.dart new file mode 100644 index 00000000..1058192e --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/platform_webview_asset_loader.g.dart @@ -0,0 +1,78 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'platform_webview_asset_loader.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Helper class to load local files including application's static assets and resources using http(s):// URLs inside a [WebView] class. +///Loading local files using web-like URLs instead of `file://` is desirable as it is compatible with the Same-Origin policy. +/// +///For more context about application's assets and resources and how to normally access them please refer to +///[Android Developer Docs: App resources overview](https://developer.android.com/guide/topics/resources/providing-resources). +/// +///Using http(s):// URLs to access local resources may conflict with a real website. +///This means that local files should only be hosted on domains your organization owns +///(at paths reserved for this purpose) or the default domain reserved for this: `appassets.androidplatform.net`. +/// +///**Supported Platforms/Implementations**: +///- Android native WebView +class WebViewAssetLoader { + ///An unused domain reserved for Android applications to intercept requests for app assets. + /// + ///It is used by default unless the user specified a different domain. + static final String DEFAULT_DOMAIN = "appassets.androidplatform.net"; + + ///Set the domain under which app assets can be accessed. The default domain is `appassets.androidplatform.net`. + String? domain; + + ///Allow using the HTTP scheme in addition to HTTPS. The default is to not allow HTTP. + bool? httpAllowed; + + ///List of registered path handlers. + /// + ///[WebViewAssetLoader] will try Path Handlers in the order they're registered, + ///and will use whichever is the first to return a non-null. + List? pathHandlers; + WebViewAssetLoader({this.domain, this.httpAllowed, this.pathHandlers}); + + ///Gets a possible [WebViewAssetLoader] instance from a [Map] value. + static WebViewAssetLoader? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = WebViewAssetLoader( + domain: map['domain'], + httpAllowed: map['httpAllowed'], + pathHandlers: map['pathHandlers'] != null + ? List.from(map['pathHandlers'].map((e) => e)) + : null, + ); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "domain": domain, + "httpAllowed": httpAllowed, + "pathHandlers": pathHandlers?.map((e) => e.toMap()).toList(), + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + ///Returns a copy of WebViewAssetLoader. + WebViewAssetLoader copy() { + return WebViewAssetLoader.fromMap(toMap()) ?? WebViewAssetLoader(); + } + + @override + String toString() { + return 'WebViewAssetLoader{domain: $domain, httpAllowed: $httpAllowed, pathHandlers: $pathHandlers}'; + } +} diff --git a/flutter_inappwebview_platform_interface/lib/src/web_message/platform_web_message_port.dart b/flutter_inappwebview_platform_interface/lib/src/web_message/platform_web_message_port.dart index e57b4ec4..bbaf9861 100644 --- a/flutter_inappwebview_platform_interface/lib/src/web_message/platform_web_message_port.dart +++ b/flutter_inappwebview_platform_interface/lib/src/web_message/platform_web_message_port.dart @@ -12,8 +12,7 @@ import 'web_message.dart'; @immutable class PlatformWebMessagePortCreationParams { /// Used by the platform implementation to create a new [PlatformWebMessagePort]. - const PlatformWebMessagePortCreationParams( - {required this.index}); + const PlatformWebMessagePortCreationParams({required this.index}); ///Port index. final int index; @@ -42,19 +41,19 @@ class PlatformWebMessagePortCreationParams { ///A transferred port cannot be closed by the application, since the ownership is also transferred. /// ///It is possible to transfer both ports of a channel to JavaScript, for example for communication between subframes. -abstract class PlatformWebMessagePort extends PlatformInterface { +abstract class PlatformWebMessagePort extends PlatformInterface + implements IWebMessagePort { /// Creates a new [PlatformWebMessagePort] - factory PlatformWebMessagePort( - PlatformWebMessagePortCreationParams params) { + factory PlatformWebMessagePort(PlatformWebMessagePortCreationParams params) { assert( - InAppWebViewPlatform.instance != null, - 'A platform implementation for `flutter_inappwebview` has not been set. Please ' - 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' - '`InAppWebViewPlatform.instance` before use. For unit testing, ' - '`InAppWebViewPlatform.instance` can be set with your own test implementation.', + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`InAppWebViewPlatform.instance` before use. For unit testing, ' + '`InAppWebViewPlatform.instance` can be set with your own test implementation.', ); final PlatformWebMessagePort webMessagePort = - InAppWebViewPlatform.instance!.createPlatformWebMessagePort(params); + InAppWebViewPlatform.instance!.createPlatformWebMessagePort(params); PlatformInterface.verify(webMessagePort, _token); return webMessagePort; } @@ -71,6 +70,13 @@ abstract class PlatformWebMessagePort extends PlatformInterface { /// The parameters used to initialize the [PlatformWebMessagePort]. final PlatformWebMessagePortCreationParams params; + @override + String toString() { + return 'PlatformWebMessagePort{index: ${params.index}}'; + } +} + +abstract class IWebMessagePort { ///Sets a callback to receive message events on the main thread. Future setWebMessageCallback(WebMessageCallback? onMessage) { throw UnimplementedError( @@ -98,9 +104,4 @@ abstract class PlatformWebMessagePort extends PlatformInterface { throw UnimplementedError( 'toJson is not implemented on the current platform'); } - - @override - String toString() { - return 'PlatformWebMessagePort{params: $params}'; - } } diff --git a/flutter_inappwebview_platform_interface/lib/src/web_message/web_message.dart b/flutter_inappwebview_platform_interface/lib/src/web_message/web_message.dart index 83de838d..33476b95 100644 --- a/flutter_inappwebview_platform_interface/lib/src/web_message/web_message.dart +++ b/flutter_inappwebview_platform_interface/lib/src/web_message/web_message.dart @@ -17,7 +17,7 @@ class WebMessage_ { WebMessageType_ type; ///The ports that are sent with the message. - List? ports; + List? ports; @ExchangeableObjectConstructor() WebMessage_({this.data, this.type = WebMessageType_.STRING, this.ports}) { diff --git a/flutter_inappwebview_platform_interface/lib/src/web_message/web_message.g.dart b/flutter_inappwebview_platform_interface/lib/src/web_message/web_message.g.dart index 761fae59..facac8e4 100644 --- a/flutter_inappwebview_platform_interface/lib/src/web_message/web_message.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/web_message/web_message.g.dart @@ -91,7 +91,7 @@ class WebMessage { dynamic data; ///The ports that are sent with the message. - List? ports; + List? ports; ///The payload type of the message. WebMessageType type; @@ -111,7 +111,7 @@ class WebMessage { final instance = WebMessage( data: map['data'], ports: map['ports'] != null - ? List.from(map['ports'].map((e) => e)) + ? List.from(map['ports'].map((e) => e)) : null, type: WebMessageType.fromNativeValue(map['type'])!, ); diff --git a/lib/src/chrome_safari_browser/chrome_safari_browser.dart b/lib/src/chrome_safari_browser/chrome_safari_browser.dart index ccb11d7f..b2afc253 100755 --- a/lib/src/chrome_safari_browser/chrome_safari_browser.dart +++ b/lib/src/chrome_safari_browser/chrome_safari_browser.dart @@ -16,156 +16,36 @@ import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_pla ///**Supported Platforms/Implementations**: ///- Android ///- iOS -class ChromeSafariBrowser extends ChannelController { +class ChromeSafariBrowser implements PlatformChromeSafariBrowserEvents { ///Debug settings. static DebugLoggingSettings debugLoggingSettings = DebugLoggingSettings(); - ///View ID used internally. - late final String id; + /// Constructs a [ChromeSafariBrowser]. + /// + /// See [ChromeSafariBrowser.fromPlatformCreationParams] for setting + /// parameters for a specific platform. + ChromeSafariBrowser() + : this.fromPlatformCreationParams( + PlatformChromeSafariBrowserCreationParams(), + ); - ChromeSafariBrowserActionButton? _actionButton; - Map _menuItems = new HashMap(); - ChromeSafariBrowserSecondaryToolbar? _secondaryToolbar; - bool _isOpened = false; - static const MethodChannel _sharedChannel = - const MethodChannel('com.pichillilorenzo/flutter_chromesafaribrowser'); + /// Constructs a [ChromeSafariBrowser] from creation params for a specific + /// platform. + ChromeSafariBrowser.fromPlatformCreationParams( + PlatformChromeSafariBrowserCreationParams params, + ) : this.fromPlatform(PlatformChromeSafariBrowser(params)); - ChromeSafariBrowser() { - id = IdGenerator.generate(); - channel = - MethodChannel('com.pichillilorenzo/flutter_chromesafaribrowser_$id'); - handler = _handleMethod; - initMethodCallHandler(); - _isOpened = false; + /// Constructs a [ChromeSafariBrowser] from a specific platform + /// implementation. + ChromeSafariBrowser.fromPlatform(this.platform) { + this.platform.eventHandler = this; } - _init() { - channel = - MethodChannel('com.pichillilorenzo/flutter_chromesafaribrowser_$id'); - handler = _handleMethod; - initMethodCallHandler(); - } + /// Implementation of [PlatformWebViewChromeSafariBrowser] for the current platform. + final PlatformChromeSafariBrowser platform; - _debugLog(String method, dynamic args) { - debugLog( - className: this.runtimeType.toString(), - id: id, - debugLoggingSettings: ChromeSafariBrowser.debugLoggingSettings, - method: method, - args: args); - } - - Future _handleMethod(MethodCall call) async { - _debugLog(call.method, call.arguments); - - switch (call.method) { - case "onServiceConnected": - onServiceConnected(); - break; - case "onOpened": - onOpened(); - break; - case "onCompletedInitialLoad": - final bool? didLoadSuccessfully = call.arguments["didLoadSuccessfully"]; - onCompletedInitialLoad(didLoadSuccessfully); - break; - case "onInitialLoadDidRedirect": - final String? url = call.arguments["url"]; - final WebUri? uri = url != null ? WebUri(url) : null; - onInitialLoadDidRedirect(uri); - break; - case "onNavigationEvent": - final navigationEvent = CustomTabsNavigationEventType.fromNativeValue( - call.arguments["navigationEvent"]); - onNavigationEvent(navigationEvent); - break; - case "onRelationshipValidationResult": - final relation = - CustomTabsRelationType.fromNativeValue(call.arguments["relation"]); - final requestedOrigin = call.arguments["requestedOrigin"] != null - ? WebUri(call.arguments["requestedOrigin"]) - : null; - final bool result = call.arguments["result"]; - onRelationshipValidationResult(relation, requestedOrigin, result); - break; - case "onWillOpenInBrowser": - onWillOpenInBrowser(); - break; - case "onClosed": - _isOpened = false; - dispose(); - onClosed(); - break; - case "onItemActionPerform": - String url = call.arguments["url"]; - String title = call.arguments["title"]; - int id = call.arguments["id"].toInt(); - if (this._actionButton?.id == id) { - if (this._actionButton?.action != null) { - this._actionButton?.action!(url, title); - } - if (this._actionButton?.onClick != null) { - this._actionButton?.onClick!(WebUri(url), title); - } - } else if (this._menuItems[id] != null) { - if (this._menuItems[id]?.action != null) { - this._menuItems[id]?.action!(url, title); - } - if (this._menuItems[id]?.onClick != null) { - this._menuItems[id]?.onClick!(WebUri(url), title); - } - } - break; - case "onSecondaryItemActionPerform": - final clickableIDs = this._secondaryToolbar?.clickableIDs; - if (clickableIDs != null) { - WebUri? url = call.arguments["url"] != null - ? WebUri(call.arguments["url"]) - : null; - String name = call.arguments["name"]; - for (final clickable in clickableIDs) { - var clickableFullname = clickable.id.name; - if (clickable.id.defType != null && - !clickableFullname.contains("/")) { - clickableFullname = "${clickable.id.defType}/$clickableFullname"; - } - if (clickable.id.defPackage != null && - !clickableFullname.contains(":")) { - clickableFullname = - "${clickable.id.defPackage}:$clickableFullname"; - } - if (clickableFullname == name) { - if (clickable.onClick != null) { - clickable.onClick!(url); - } - break; - } - } - } - break; - case "onMessageChannelReady": - onMessageChannelReady(); - break; - case "onPostMessage": - final String message = call.arguments["message"]; - onPostMessage(message); - break; - case "onVerticalScrollEvent": - final bool isDirectionUp = call.arguments["isDirectionUp"]; - onVerticalScrollEvent(isDirectionUp); - break; - case "onGreatestScrollPercentageIncreased": - final int scrollPercentage = call.arguments["scrollPercentage"]; - onGreatestScrollPercentageIncreased(scrollPercentage); - break; - case "onSessionEnded": - final bool didUserInteract = call.arguments["didUserInteract"]; - onSessionEnded(didUserInteract); - break; - default: - throw UnimplementedError("Unimplemented ${call.method} method"); - } - } + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.id} + String get id => platform.id; ///Opens the [ChromeSafariBrowser] instance with an [url]. /// @@ -187,50 +67,20 @@ class ChromeSafariBrowser extends ChannelController { ///- Android ///- iOS Future open( - {WebUri? url, - Map? headers, - List? otherLikelyURLs, - WebUri? referrer, - @Deprecated('Use settings instead') - // ignore: deprecated_member_use_from_same_package - ChromeSafariBrowserClassOptions? options, - ChromeSafariBrowserSettings? settings}) async { - assert(!_isOpened, 'The browser is already opened.'); - _isOpened = true; - - if (Util.isIOS) { - assert(url != null, 'The specified URL must not be null on iOS.'); - assert(['http', 'https'].contains(url!.scheme), - 'The specified URL has an unsupported scheme. Only HTTP and HTTPS URLs are supported on iOS.'); - } - if (url != null) { - assert(url.toString().isNotEmpty, 'The specified URL must not be empty.'); - } - - _init(); - - List> menuItemList = []; - _menuItems.forEach((key, value) { - menuItemList.add(value.toMap()); - }); - - var initialSettings = settings?.toMap() ?? - options?.toMap() ?? - ChromeSafariBrowserSettings().toMap(); - - Map args = {}; - args.putIfAbsent('id', () => id); - args.putIfAbsent('url', () => url?.toString()); - args.putIfAbsent('headers', () => headers); - args.putIfAbsent('otherLikelyURLs', - () => otherLikelyURLs?.map((e) => e.toString()).toList()); - args.putIfAbsent('referrer', () => referrer?.toString()); - args.putIfAbsent('settings', () => initialSettings); - args.putIfAbsent('actionButton', () => _actionButton?.toMap()); - args.putIfAbsent('secondaryToolbar', () => _secondaryToolbar?.toMap()); - args.putIfAbsent('menuItemList', () => menuItemList); - await _sharedChannel.invokeMethod('open', args); - } + {WebUri? url, + Map? headers, + List? otherLikelyURLs, + WebUri? referrer, + @Deprecated('Use settings instead') + // ignore: deprecated_member_use_from_same_package + ChromeSafariBrowserClassOptions? options, + ChromeSafariBrowserSettings? settings}) => + platform.open( + url: url, + headers: headers, + otherLikelyURLs: otherLikelyURLs, + options: options, + settings: settings); ///Tells the browser to launch with [url]. /// @@ -251,15 +101,12 @@ class ChromeSafariBrowser extends ChannelController { Map? headers, List? otherLikelyURLs, WebUri? referrer, - }) async { - Map args = {}; - args.putIfAbsent('url', () => url.toString()); - args.putIfAbsent('headers', () => headers); - args.putIfAbsent('otherLikelyURLs', - () => otherLikelyURLs?.map((e) => e.toString()).toList()); - args.putIfAbsent('referrer', () => referrer?.toString()); - await channel?.invokeMethod("launchUrl", args); - } + }) => + platform.launchUrl( + url: url, + headers: headers, + otherLikelyURLs: otherLikelyURLs, + referrer: referrer); ///Tells the browser of a likely future navigation to a URL. ///The most likely URL has to be specified first. @@ -273,14 +120,8 @@ class ChromeSafariBrowser extends ChannelController { /// ///**Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsSession.mayLaunchUrl](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#mayLaunchUrl(android.net.Uri,android.os.Bundle,java.util.List%3Candroid.os.Bundle%3E))) - Future mayLaunchUrl( - {WebUri? url, List? otherLikelyURLs}) async { - Map args = {}; - args.putIfAbsent('url', () => url?.toString()); - args.putIfAbsent('otherLikelyURLs', - () => otherLikelyURLs?.map((e) => e.toString()).toList()); - return await channel?.invokeMethod("mayLaunchUrl", args) ?? false; - } + Future mayLaunchUrl({WebUri? url, List? otherLikelyURLs}) => + platform.mayLaunchUrl(url: url, otherLikelyURLs: otherLikelyURLs); ///Requests to validate a relationship between the application and an origin. /// @@ -299,24 +140,22 @@ class ChromeSafariBrowser extends ChannelController { ///**Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsSession.validateRelationship](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#validateRelationship(int,android.net.Uri,android.os.Bundle))) Future validateRelationship( - {required CustomTabsRelationType relation, - required WebUri origin}) async { - Map args = {}; - args.putIfAbsent('relation', () => relation.toNativeValue()); - args.putIfAbsent('origin', () => origin.toString()); - return await channel?.invokeMethod("validateRelationship", args) ?? - false; - } + {required CustomTabsRelationType relation, required WebUri origin}) => + platform.validateRelationship(relation: relation, origin: origin); ///Closes the [ChromeSafariBrowser] instance. /// ///**Supported Platforms/Implementations**: ///- Android ///- iOS - Future close() async { - Map args = {}; - await channel?.invokeMethod("close", args); - } + Future close() => platform.close(); + + ///Returns `true` if the [ChromeSafariBrowser] instance is opened, otherwise `false`. + /// + ///**Supported Platforms/Implementations**: + ///- Android + ///- iOS + bool isOpened() => platform.isOpened(); ///Set a custom action button. /// @@ -324,9 +163,8 @@ class ChromeSafariBrowser extends ChannelController { /// ///**Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsIntent.Builder.setActionButton](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsIntent.Builder#setActionButton(android.graphics.Bitmap,%20java.lang.String,%20android.app.PendingIntent,%20boolean))) - void setActionButton(ChromeSafariBrowserActionButton actionButton) { - this._actionButton = actionButton; - } + void setActionButton(ChromeSafariBrowserActionButton actionButton) => + platform.setActionButton(actionButton); ///Updates the [ChromeSafariBrowserActionButton.icon] and [ChromeSafariBrowserActionButton.description]. /// @@ -335,14 +173,8 @@ class ChromeSafariBrowser extends ChannelController { ///**Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsSession.setActionButton](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#setActionButton(android.graphics.Bitmap,java.lang.String))) Future updateActionButton( - {required Uint8List icon, required String description}) async { - Map args = {}; - args.putIfAbsent('icon', () => icon); - args.putIfAbsent('description', () => description); - await channel?.invokeMethod("updateActionButton", args); - _actionButton?.icon = icon; - _actionButton?.description = description; - } + {required Uint8List icon, required String description}) => + platform.updateActionButton(icon: icon, description: description); ///Sets the remote views displayed in the secondary toolbar in a custom tab. /// @@ -351,9 +183,8 @@ class ChromeSafariBrowser extends ChannelController { ///**Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsIntent.Builder.setSecondaryToolbarViews](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsIntent.Builder#setSecondaryToolbarViews(android.widget.RemoteViews,int[],android.app.PendingIntent))) void setSecondaryToolbar( - ChromeSafariBrowserSecondaryToolbar secondaryToolbar) { - this._secondaryToolbar = secondaryToolbar; - } + ChromeSafariBrowserSecondaryToolbar secondaryToolbar) => + platform.setSecondaryToolbar(secondaryToolbar); ///Sets or updates (if already present) the Remote Views of the secondary toolbar in an existing custom tab session. /// @@ -362,12 +193,8 @@ class ChromeSafariBrowser extends ChannelController { ///**Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsSession.setSecondaryToolbarViews](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#setSecondaryToolbarViews(android.widget.RemoteViews,int[],android.app.PendingIntent))) Future updateSecondaryToolbar( - ChromeSafariBrowserSecondaryToolbar secondaryToolbar) async { - Map args = {}; - args.putIfAbsent('secondaryToolbar', () => secondaryToolbar.toMap()); - await channel?.invokeMethod("updateSecondaryToolbar", args); - this._secondaryToolbar = secondaryToolbar; - } + ChromeSafariBrowserSecondaryToolbar secondaryToolbar) => + platform.updateSecondaryToolbar(secondaryToolbar); ///Adds a [ChromeSafariBrowserMenuItem] to the menu. /// @@ -376,9 +203,8 @@ class ChromeSafariBrowser extends ChannelController { ///**Supported Platforms/Implementations**: ///- Android ///- iOS - void addMenuItem(ChromeSafariBrowserMenuItem menuItem) { - this._menuItems[menuItem.id] = menuItem; - } + void addMenuItem(ChromeSafariBrowserMenuItem menuItem) => + platform.addMenuItem(menuItem); ///Adds a list of [ChromeSafariBrowserMenuItem] to the menu. /// @@ -387,11 +213,8 @@ class ChromeSafariBrowser extends ChannelController { ///**Supported Platforms/Implementations**: ///- Android ///- iOS - void addMenuItems(List menuItems) { - menuItems.forEach((menuItem) { - this._menuItems[menuItem.id] = menuItem; - }); - } + void addMenuItems(List menuItems) => + platform.addMenuItems(menuItems); ///Sends a request to create a two way postMessage channel between the client ///and the browser. @@ -411,14 +234,9 @@ class ChromeSafariBrowser extends ChannelController { ///**Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsSession.requestPostMessageChannel](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#requestPostMessageChannel(android.net.Uri,android.net.Uri,android.os.Bundle))) Future requestPostMessageChannel( - {required WebUri sourceOrigin, WebUri? targetOrigin}) async { - Map args = {}; - args.putIfAbsent("sourceOrigin", () => sourceOrigin.toString()); - args.putIfAbsent("targetOrigin", () => targetOrigin.toString()); - return await channel?.invokeMethod( - "requestPostMessageChannel", args) ?? - false; - } + {required WebUri sourceOrigin, WebUri? targetOrigin}) => + platform.requestPostMessageChannel( + sourceOrigin: sourceOrigin, targetOrigin: targetOrigin); ///Sends a postMessage request using the origin communicated via [requestPostMessageChannel]. ///Fails when called before [onMessageChannelReady] event. @@ -430,13 +248,8 @@ class ChromeSafariBrowser extends ChannelController { /// ///**Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsSession.postMessage](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#postMessage(java.lang.String,android.os.Bundle))) - Future postMessage(String message) async { - Map args = {}; - args.putIfAbsent("message", () => message); - return CustomTabsPostMessageResultType.fromNativeValue( - await channel?.invokeMethod("postMessage", args)) ?? - CustomTabsPostMessageResultType.FAILURE_MESSAGING_ERROR; - } + Future postMessage(String message) => + platform.postMessage(message); ///Returns whether the Engagement Signals API is available. ///The availability of the Engagement Signals API may change at runtime. @@ -447,12 +260,8 @@ class ChromeSafariBrowser extends ChannelController { /// ///**Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsSession.isEngagementSignalsApiAvailable](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#isEngagementSignalsApiAvailable(android.os.Bundle))) - Future isEngagementSignalsApiAvailable() async { - Map args = {}; - return await channel?.invokeMethod( - "isEngagementSignalsApiAvailable", args) ?? - false; - } + Future isEngagementSignalsApiAvailable() => + platform.isEngagementSignalsApiAvailable(); ///On Android, returns `true` if Chrome Custom Tabs is available. ///On iOS, returns `true` if SFSafariViewController is available. @@ -461,21 +270,15 @@ class ChromeSafariBrowser extends ChannelController { ///**Supported Platforms/Implementations**: ///- Android ///- iOS - static Future isAvailable() async { - Map args = {}; - return await _sharedChannel.invokeMethod("isAvailable", args) ?? - false; - } + static Future isAvailable() => + PlatformChromeSafariBrowser.static().isAvailable(); ///The maximum number of allowed secondary toolbar items. /// ///**Supported Platforms/Implementations**: ///- Android - static Future getMaxToolbarItems() async { - Map args = {}; - return await _sharedChannel.invokeMethod("getMaxToolbarItems", args) ?? - 0; - } + static Future getMaxToolbarItems() => + PlatformChromeSafariBrowser.static().getMaxToolbarItems(); ///Returns the preferred package to use for Custom Tabs. ///The preferred package name is the default VIEW intent handler as long as it supports Custom Tabs. @@ -494,12 +297,9 @@ class ChromeSafariBrowser extends ChannelController { ///**Supported Platforms/Implementations**: ///- Android ([Official API - CustomTabsClient.getPackageName](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsClient#getPackageName(android.content.Context,java.util.List%3Cjava.lang.String%3E,boolean)))) static Future getPackageName( - {List? packages, bool ignoreDefault = false}) async { - Map args = {}; - args.putIfAbsent("packages", () => packages); - args.putIfAbsent("ignoreDefault", () => ignoreDefault); - return await _sharedChannel.invokeMethod("getPackageName", args); - } + {List? packages, bool ignoreDefault = false}) => + PlatformChromeSafariBrowser.static() + .getPackageName(packages: packages, ignoreDefault: ignoreDefault); ///Clear associated website data accrued from browsing activity within your app. ///This includes all local storage, cached resources, and cookies. @@ -508,10 +308,8 @@ class ChromeSafariBrowser extends ChannelController { /// ///**Supported Platforms/Implementations**: ///- iOS ([Official API - SFSafariViewController.DataStore.clearWebsiteData](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/datastore/3981117-clearwebsitedata)) - static Future clearWebsiteData() async { - Map args = {}; - await _sharedChannel.invokeMethod("clearWebsiteData", args); - } + static Future clearWebsiteData() => + PlatformChromeSafariBrowser.static().clearWebsiteData(); ///Prewarms a connection to each URL. SFSafariViewController will automatically use a ///prewarmed connection if possible when loading its initial URL. @@ -533,14 +331,8 @@ class ChromeSafariBrowser extends ChannelController { /// ///**Supported Platforms/Implementations**: ///- iOS ([Official API - SFSafariViewController.prewarmConnections](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/3752133-prewarmconnections)) - static Future prewarmConnections(List URLs) async { - Map args = {}; - args.putIfAbsent('URLs', () => URLs.map((e) => e.toString()).toList()); - Map? result = - (await _sharedChannel.invokeMethod("prewarmConnections", args)) - ?.cast(); - return PrewarmingToken.fromMap(result); - } + static Future prewarmConnections(List URLs) => + PlatformChromeSafariBrowser.static().prewarmConnections(URLs); ///Ends all prewarmed connections associated with the token, except for connections that are also kept alive by other tokens. /// @@ -549,11 +341,9 @@ class ChromeSafariBrowser extends ChannelController { ///**Supported Platforms/Implementations**: ///- iOS ([Official API - SFSafariViewController.prewarmConnections](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/3752133-prewarmconnections)) static Future invalidatePrewarmingToken( - PrewarmingToken prewarmingToken) async { - Map args = {}; - args.putIfAbsent('prewarmingToken', () => prewarmingToken.toMap()); - await _sharedChannel.invokeMethod("invalidatePrewarmingToken", args); - } + PrewarmingToken prewarmingToken) => + PlatformChromeSafariBrowser.static() + .invalidatePrewarmingToken(prewarmingToken); ///Event fired when the when connecting from Android Custom Tabs Service. /// @@ -668,19 +458,7 @@ class ChromeSafariBrowser extends ChannelController { ///- iOS void onClosed() {} - ///Returns `true` if the [ChromeSafariBrowser] instance is opened, otherwise `false`. - /// - ///**Supported Platforms/Implementations**: - ///- Android - ///- iOS - bool isOpened() { - return _isOpened; - } - ///Disposes the channel. - @override @mustCallSuper - void dispose() { - disposeChannel(); - } + void dispose() => platform.dispose(); } diff --git a/lib/src/in_app_webview/headless_in_app_webview.dart b/lib/src/in_app_webview/headless_in_app_webview.dart index dfd6dc6f..31ff796e 100644 --- a/lib/src/in_app_webview/headless_in_app_webview.dart +++ b/lib/src/in_app_webview/headless_in_app_webview.dart @@ -52,23 +52,21 @@ class HeadlessInAppWebView { InAppWebViewKeepAlive? keepAlive, bool? preventGestureDelay, @Deprecated('Use onGeolocationPermissionsHidePrompt instead') - void Function(PlatformInAppWebViewController controller)? + void Function(InAppWebViewController controller)? androidOnGeolocationPermissionsHidePrompt, @Deprecated('Use onGeolocationPermissionsShowPrompt instead') Future Function( - PlatformInAppWebViewController controller, String origin)? + InAppWebViewController controller, String origin)? androidOnGeolocationPermissionsShowPrompt, @Deprecated('Use onPermissionRequest instead') Future Function( - PlatformInAppWebViewController controller, + InAppWebViewController controller, String origin, List resources)? androidOnPermissionRequest, @Deprecated('Use onSafeBrowsingHit instead') - Future Function( - PlatformInAppWebViewController controller, - Uri url, - SafeBrowsingThreat? threatType)? + Future Function(InAppWebViewController controller, + Uri url, SafeBrowsingThreat? threatType)? androidOnSafeBrowsingHit, InAppWebViewInitialData? initialData, String? initialFile, @@ -80,252 +78,233 @@ class HeadlessInAppWebView { PullToRefreshController? pullToRefreshController, FindInteractionController? findInteractionController, ContextMenu? contextMenu, - void Function(PlatformInAppWebViewController controller, WebUri? url)? + void Function(InAppWebViewController controller, WebUri? url)? onPageCommitVisible, - void Function(PlatformInAppWebViewController controller, String? title)? + void Function(InAppWebViewController controller, String? title)? onTitleChanged, @Deprecated( 'Use onDidReceiveServerRedirectForProvisionalNavigation instead') - void Function(PlatformInAppWebViewController controller)? + void Function(InAppWebViewController controller)? iosOnDidReceiveServerRedirectForProvisionalNavigation, @Deprecated('Use onWebContentProcessDidTerminate instead') - void Function(PlatformInAppWebViewController controller)? + void Function(InAppWebViewController controller)? iosOnWebContentProcessDidTerminate, @Deprecated('Use onNavigationResponse instead') Future Function( - PlatformInAppWebViewController controller, + InAppWebViewController controller, IOSWKNavigationResponse navigationResponse)? iosOnNavigationResponse, @Deprecated('Use shouldAllowDeprecatedTLS instead') Future Function( - PlatformInAppWebViewController controller, + InAppWebViewController controller, URLAuthenticationChallenge challenge)? iosShouldAllowDeprecatedTLS, Future Function( - PlatformInAppWebViewController controller, AjaxRequest ajaxRequest)? + InAppWebViewController controller, AjaxRequest ajaxRequest)? onAjaxProgress, Future Function( - PlatformInAppWebViewController controller, AjaxRequest ajaxRequest)? + InAppWebViewController controller, AjaxRequest ajaxRequest)? onAjaxReadyStateChange, - void Function(PlatformInAppWebViewController controller, - ConsoleMessage consoleMessage)? + void Function( + InAppWebViewController controller, ConsoleMessage consoleMessage)? onConsoleMessage, - Future Function(PlatformInAppWebViewController controller, + Future Function(InAppWebViewController controller, CreateWindowAction createWindowAction)? onCreateWindow, - void Function(PlatformInAppWebViewController controller)? onCloseWindow, - void Function(PlatformInAppWebViewController controller)? onWindowFocus, - void Function(PlatformInAppWebViewController controller)? onWindowBlur, + void Function(InAppWebViewController controller)? onCloseWindow, + void Function(InAppWebViewController controller)? onWindowFocus, + void Function(InAppWebViewController controller)? onWindowBlur, @Deprecated('Use onReceivedIcon instead') - void Function(PlatformInAppWebViewController controller, Uint8List icon)? + void Function(InAppWebViewController controller, Uint8List icon)? androidOnReceivedIcon, @Deprecated('Use onReceivedTouchIconUrl instead') - void Function(PlatformInAppWebViewController controller, Uri url, - bool precomposed)? + void Function(InAppWebViewController controller, Uri url, bool precomposed)? androidOnReceivedTouchIconUrl, @Deprecated('Use onDownloadStartRequest instead') - void Function(PlatformInAppWebViewController controller, Uri url)? - onDownloadStart, - void Function(PlatformInAppWebViewController controller, + void Function(InAppWebViewController controller, Uri url)? onDownloadStart, + void Function(InAppWebViewController controller, DownloadStartRequest downloadStartRequest)? onDownloadStartRequest, @Deprecated('Use FindInteractionController.onFindResultReceived instead') - void Function(PlatformInAppWebViewController controller, - int activeMatchOrdinal, int numberOfMatches, bool isDoneCounting)? + void Function(InAppWebViewController controller, int activeMatchOrdinal, + int numberOfMatches, bool isDoneCounting)? onFindResultReceived, - Future Function(PlatformInAppWebViewController controller, - JsAlertRequest jsAlertRequest)? + Future Function( + InAppWebViewController controller, JsAlertRequest jsAlertRequest)? onJsAlert, - Future Function( - PlatformInAppWebViewController controller, + Future Function(InAppWebViewController controller, JsConfirmRequest jsConfirmRequest)? onJsConfirm, Future Function( - PlatformInAppWebViewController controller, - JsPromptRequest jsPromptRequest)? + InAppWebViewController controller, JsPromptRequest jsPromptRequest)? onJsPrompt, @Deprecated("Use onReceivedError instead") - void Function(PlatformInAppWebViewController controller, Uri? url, int code, + void Function(InAppWebViewController controller, Uri? url, int code, String message)? onLoadError, - void Function(PlatformInAppWebViewController controller, - WebResourceRequest request, WebResourceError error)? + void Function(InAppWebViewController controller, WebResourceRequest request, + WebResourceError error)? onReceivedError, @Deprecated("Use onReceivedHttpError instead") - void Function(PlatformInAppWebViewController controller, Uri? url, - int statusCode, String description)? + void Function(InAppWebViewController controller, Uri? url, int statusCode, + String description)? onLoadHttpError, - void Function(PlatformInAppWebViewController controller, - WebResourceRequest request, WebResourceResponse errorResponse)? + void Function(InAppWebViewController controller, WebResourceRequest request, + WebResourceResponse errorResponse)? onReceivedHttpError, - void Function( - PlatformInAppWebViewController controller, LoadedResource resource)? + void Function(InAppWebViewController controller, LoadedResource resource)? onLoadResource, @Deprecated('Use onLoadResourceWithCustomScheme instead') Future Function( - PlatformInAppWebViewController controller, Uri url)? + InAppWebViewController controller, Uri url)? onLoadResourceCustomScheme, Future Function( - PlatformInAppWebViewController controller, - WebResourceRequest request)? + InAppWebViewController controller, WebResourceRequest request)? onLoadResourceWithCustomScheme, - void Function(PlatformInAppWebViewController controller, WebUri? url)? - onLoadStart, - void Function(PlatformInAppWebViewController controller, WebUri? url)? - onLoadStop, - void Function(PlatformInAppWebViewController controller, + void Function(InAppWebViewController controller, WebUri? url)? onLoadStart, + void Function(InAppWebViewController controller, WebUri? url)? onLoadStop, + void Function(InAppWebViewController controller, InAppWebViewHitTestResult hitTestResult)? onLongPressHitTestResult, @Deprecated("Use onPrintRequest instead") - void Function(PlatformInAppWebViewController controller, Uri? url)? onPrint, - Future Function(PlatformInAppWebViewController controller, - WebUri? url, PlatformPrintJobController? printJobController)? + void Function(InAppWebViewController controller, Uri? url)? onPrint, + Future Function(InAppWebViewController controller, WebUri? url, + PlatformPrintJobController? printJobController)? onPrintRequest, - void Function(PlatformInAppWebViewController controller, int progress)? + void Function(InAppWebViewController controller, int progress)? onProgressChanged, - Future Function( - PlatformInAppWebViewController controller, + Future Function(InAppWebViewController controller, URLAuthenticationChallenge challenge)? onReceivedClientCertRequest, - Future Function( - PlatformInAppWebViewController controller, + Future Function(InAppWebViewController controller, URLAuthenticationChallenge challenge)? onReceivedHttpAuthRequest, - Future Function( - PlatformInAppWebViewController controller, + Future Function(InAppWebViewController controller, URLAuthenticationChallenge challenge)? onReceivedServerTrustAuthRequest, - void Function(PlatformInAppWebViewController controller, int x, int y)? + void Function(InAppWebViewController controller, int x, int y)? onScrollChanged, - void Function(PlatformInAppWebViewController controller, WebUri? url, - bool? isReload)? + void Function( + InAppWebViewController controller, WebUri? url, bool? isReload)? onUpdateVisitedHistory, - void Function(PlatformInAppWebViewController controller)? onWebViewCreated, + void Function(InAppWebViewController controller)? onWebViewCreated, Future Function( - PlatformInAppWebViewController controller, AjaxRequest ajaxRequest)? + InAppWebViewController controller, AjaxRequest ajaxRequest)? shouldInterceptAjaxRequest, - Future Function(PlatformInAppWebViewController controller, - FetchRequest fetchRequest)? + Future Function( + InAppWebViewController controller, FetchRequest fetchRequest)? shouldInterceptFetchRequest, - Future Function( - PlatformInAppWebViewController controller, + Future Function(InAppWebViewController controller, NavigationAction navigationAction)? shouldOverrideUrlLoading, - void Function(PlatformInAppWebViewController controller)? onEnterFullscreen, - void Function(PlatformInAppWebViewController controller)? onExitFullscreen, - void Function(PlatformInAppWebViewController controller, int x, int y, + void Function(InAppWebViewController controller)? onEnterFullscreen, + void Function(InAppWebViewController controller)? onExitFullscreen, + void Function(InAppWebViewController controller, int x, int y, bool clampedX, bool clampedY)? onOverScrolled, - void Function(PlatformInAppWebViewController controller, double oldScale, + void Function(InAppWebViewController controller, double oldScale, double newScale)? onZoomScaleChanged, @Deprecated('Use shouldInterceptRequest instead') Future Function( - PlatformInAppWebViewController controller, - WebResourceRequest request)? + InAppWebViewController controller, WebResourceRequest request)? androidShouldInterceptRequest, @Deprecated('Use onRenderProcessUnresponsive instead') Future Function( - PlatformInAppWebViewController controller, Uri? url)? + InAppWebViewController controller, Uri? url)? androidOnRenderProcessUnresponsive, @Deprecated('Use onRenderProcessResponsive instead') Future Function( - PlatformInAppWebViewController controller, Uri? url)? + InAppWebViewController controller, Uri? url)? androidOnRenderProcessResponsive, @Deprecated('Use onRenderProcessGone instead') - void Function(PlatformInAppWebViewController controller, - RenderProcessGoneDetail detail)? + void Function( + InAppWebViewController controller, RenderProcessGoneDetail detail)? androidOnRenderProcessGone, @Deprecated('Use onFormResubmission instead') Future Function( - PlatformInAppWebViewController controller, Uri? url)? + InAppWebViewController controller, Uri? url)? androidOnFormResubmission, @Deprecated('Use onZoomScaleChanged instead') - void Function(PlatformInAppWebViewController controller, double oldScale, + void Function(InAppWebViewController controller, double oldScale, double newScale)? androidOnScaleChanged, @Deprecated('Use onJsBeforeUnload instead') - Future Function( - PlatformInAppWebViewController controller, + Future Function(InAppWebViewController controller, JsBeforeUnloadRequest jsBeforeUnloadRequest)? androidOnJsBeforeUnload, @Deprecated('Use onReceivedLoginRequest instead') - void Function(PlatformInAppWebViewController controller, - LoginRequest loginRequest)? + void Function(InAppWebViewController controller, LoginRequest loginRequest)? androidOnReceivedLoginRequest, - void Function(PlatformInAppWebViewController controller)? + void Function(InAppWebViewController controller)? onDidReceiveServerRedirectForProvisionalNavigation, Future Function( - PlatformInAppWebViewController controller, WebUri? url)? + InAppWebViewController controller, WebUri? url)? onFormResubmission, - void Function(PlatformInAppWebViewController controller)? + void Function(InAppWebViewController controller)? onGeolocationPermissionsHidePrompt, Future Function( - PlatformInAppWebViewController controller, String origin)? + InAppWebViewController controller, String origin)? onGeolocationPermissionsShowPrompt, - Future Function( - PlatformInAppWebViewController controller, + Future Function(InAppWebViewController controller, JsBeforeUnloadRequest jsBeforeUnloadRequest)? onJsBeforeUnload, Future Function( - PlatformInAppWebViewController controller, + InAppWebViewController controller, NavigationResponse navigationResponse)? onNavigationResponse, - Future Function( - PlatformInAppWebViewController controller, + Future Function(InAppWebViewController controller, PermissionRequest permissionRequest)? onPermissionRequest, - void Function(PlatformInAppWebViewController controller, Uint8List icon)? + void Function(InAppWebViewController controller, Uint8List icon)? onReceivedIcon, - void Function(PlatformInAppWebViewController controller, - LoginRequest loginRequest)? + void Function(InAppWebViewController controller, LoginRequest loginRequest)? onReceivedLoginRequest, - void Function(PlatformInAppWebViewController controller, + void Function(InAppWebViewController controller, PermissionRequest permissionRequest)? onPermissionRequestCanceled, - void Function(PlatformInAppWebViewController controller)? onRequestFocus, - void Function(PlatformInAppWebViewController controller, WebUri url, - bool precomposed)? + void Function(InAppWebViewController controller)? onRequestFocus, + void Function( + InAppWebViewController controller, WebUri url, bool precomposed)? onReceivedTouchIconUrl, - void Function(PlatformInAppWebViewController controller, - RenderProcessGoneDetail detail)? + void Function( + InAppWebViewController controller, RenderProcessGoneDetail detail)? onRenderProcessGone, Future Function( - PlatformInAppWebViewController controller, WebUri? url)? + InAppWebViewController controller, WebUri? url)? onRenderProcessResponsive, Future Function( - PlatformInAppWebViewController controller, WebUri? url)? + InAppWebViewController controller, WebUri? url)? onRenderProcessUnresponsive, - Future Function( - PlatformInAppWebViewController controller, - WebUri url, - SafeBrowsingThreat? threatType)? + Future Function(InAppWebViewController controller, + WebUri url, SafeBrowsingThreat? threatType)? onSafeBrowsingHit, - void Function(PlatformInAppWebViewController controller)? + void Function(InAppWebViewController controller)? onWebContentProcessDidTerminate, Future Function( - PlatformInAppWebViewController controller, + InAppWebViewController controller, URLAuthenticationChallenge challenge)? shouldAllowDeprecatedTLS, Future Function( - PlatformInAppWebViewController controller, - WebResourceRequest request)? + InAppWebViewController controller, WebResourceRequest request)? shouldInterceptRequest, Future Function( - PlatformInAppWebViewController controller, + InAppWebViewController controller, MediaCaptureState? oldState, MediaCaptureState? newState, )? onCameraCaptureStateChanged, Future Function( - PlatformInAppWebViewController controller, + InAppWebViewController controller, MediaCaptureState? oldState, MediaCaptureState? newState, )? onMicrophoneCaptureStateChanged, - void Function(PlatformInAppWebViewController controller, - Size oldContentSize, Size newContentSize)? + void Function(InAppWebViewController controller, Size oldContentSize, + Size newContentSize)? onContentSizeChanged, }) : this.fromPlatformCreationParams( params: PlatformHeadlessInAppWebViewCreationParams( + controllerFromPlatform: (PlatformInAppWebViewController controller) => + InAppWebViewController.fromPlatform(platform: controller), initialSize: initialSize, windowId: windowId, initialUrlRequest: initialUrlRequest, @@ -337,95 +316,332 @@ class HeadlessInAppWebView { pullToRefreshController: pullToRefreshController?.platform, findInteractionController: findInteractionController?.platform, contextMenu: contextMenu, - onWebViewCreated: onWebViewCreated, - onLoadStart: onLoadStart, - onLoadStop: onLoadStop, - onLoadError: onLoadError, - onReceivedError: onReceivedError, - onLoadHttpError: onLoadHttpError, - onReceivedHttpError: onReceivedHttpError, - onConsoleMessage: onConsoleMessage, - onProgressChanged: onProgressChanged, - shouldOverrideUrlLoading: shouldOverrideUrlLoading, - onLoadResource: onLoadResource, - onScrollChanged: onScrollChanged, - onDownloadStart: onDownloadStart, - onDownloadStartRequest: onDownloadStartRequest, - onLoadResourceCustomScheme: onLoadResourceCustomScheme, - onLoadResourceWithCustomScheme: onLoadResourceWithCustomScheme, - onCreateWindow: onCreateWindow, - onCloseWindow: onCloseWindow, - onJsAlert: onJsAlert, - onJsConfirm: onJsConfirm, - onJsPrompt: onJsPrompt, - onReceivedHttpAuthRequest: onReceivedHttpAuthRequest, - onReceivedServerTrustAuthRequest: onReceivedServerTrustAuthRequest, - onReceivedClientCertRequest: onReceivedClientCertRequest, - onFindResultReceived: onFindResultReceived, - shouldInterceptAjaxRequest: shouldInterceptAjaxRequest, - onAjaxReadyStateChange: onAjaxReadyStateChange, - onAjaxProgress: onAjaxProgress, - shouldInterceptFetchRequest: shouldInterceptFetchRequest, - onUpdateVisitedHistory: onUpdateVisitedHistory, - onPrint: onPrint, - onPrintRequest: onPrintRequest, - onLongPressHitTestResult: onLongPressHitTestResult, - onEnterFullscreen: onEnterFullscreen, - onExitFullscreen: onExitFullscreen, - onPageCommitVisible: onPageCommitVisible, - onTitleChanged: onTitleChanged, - onWindowFocus: onWindowFocus, - onWindowBlur: onWindowBlur, - onOverScrolled: onOverScrolled, - onZoomScaleChanged: onZoomScaleChanged, - androidOnSafeBrowsingHit: androidOnSafeBrowsingHit, - onSafeBrowsingHit: onSafeBrowsingHit, - androidOnPermissionRequest: androidOnPermissionRequest, - onPermissionRequest: onPermissionRequest, + onWebViewCreated: onWebViewCreated != null + ? (controller) => onWebViewCreated.call(controller) + : null, + onLoadStart: onLoadStart != null + ? (controller, url) => onLoadStart.call(controller, url) + : null, + onLoadStop: onLoadStop != null + ? (controller, url) => onLoadStop.call(controller, url) + : null, + onLoadError: onLoadError != null + ? (controller, url, code, message) => + onLoadError.call(controller, url, code, message) + : null, + onReceivedError: onReceivedError != null + ? (controller, request, error) => + onReceivedError.call(controller, request, error) + : null, + onLoadHttpError: onLoadHttpError != null + ? (controller, url, statusCode, description) => + onLoadHttpError.call(controller, url, statusCode, description) + : null, + onReceivedHttpError: onReceivedHttpError != null + ? (controller, request, errorResponse) => + onReceivedHttpError.call(controller, request, errorResponse) + : null, + onConsoleMessage: onConsoleMessage != null + ? (controller, consoleMessage) => + onConsoleMessage.call(controller, consoleMessage) + : null, + onProgressChanged: onProgressChanged != null + ? (controller, progress) => + onProgressChanged.call(controller, progress) + : null, + shouldOverrideUrlLoading: shouldOverrideUrlLoading != null + ? (controller, navigationAction) => + shouldOverrideUrlLoading(controller, navigationAction) + : null, + onLoadResource: onLoadResource != null + ? (controller, resource) => + onLoadResource.call(controller, resource) + : null, + onScrollChanged: onScrollChanged != null + ? (controller, x, y) => onScrollChanged.call(controller, x, y) + : null, + onDownloadStart: onDownloadStart != null + ? (controller, url) => onDownloadStart.call(controller, url) + : null, + onDownloadStartRequest: onDownloadStartRequest != null + ? (controller, downloadStartRequest) => + onDownloadStartRequest.call(controller, downloadStartRequest) + : null, + onLoadResourceCustomScheme: onLoadResourceCustomScheme != null + ? (controller, url) => + onLoadResourceCustomScheme.call(controller, url) + : null, + onLoadResourceWithCustomScheme: onLoadResourceWithCustomScheme != null + ? (controller, request) => + onLoadResourceWithCustomScheme.call(controller, request) + : null, + onCreateWindow: onCreateWindow != null + ? (controller, createWindowAction) => + onCreateWindow.call(controller, createWindowAction) + : null, + onCloseWindow: onCloseWindow != null + ? (controller) => onCloseWindow.call(controller) + : null, + onJsAlert: onJsAlert != null + ? (controller, jsAlertRequest) => + onJsAlert.call(controller, jsAlertRequest) + : null, + onJsConfirm: onJsConfirm != null + ? (controller, jsConfirmRequest) => + onJsConfirm.call(controller, jsConfirmRequest) + : null, + onJsPrompt: onJsPrompt != null + ? (controller, jsPromptRequest) => + onJsPrompt.call(controller, jsPromptRequest) + : null, + onReceivedHttpAuthRequest: onReceivedHttpAuthRequest != null + ? (controller, challenge) => + onReceivedHttpAuthRequest.call(controller, challenge) + : null, + onReceivedServerTrustAuthRequest: onReceivedServerTrustAuthRequest != + null + ? (controller, challenge) => + onReceivedServerTrustAuthRequest.call(controller, challenge) + : null, + onReceivedClientCertRequest: onReceivedClientCertRequest != null + ? (controller, challenge) => + onReceivedClientCertRequest.call(controller, challenge) + : null, + onFindResultReceived: onFindResultReceived != null + ? (controller, activeMatchOrdinal, numberOfMatches, + isDoneCounting) => + onFindResultReceived.call(controller, activeMatchOrdinal, + numberOfMatches, isDoneCounting) + : null, + shouldInterceptAjaxRequest: shouldInterceptAjaxRequest != null + ? (controller, ajaxRequest) => + shouldInterceptAjaxRequest.call(controller, ajaxRequest) + : null, + onAjaxReadyStateChange: onAjaxReadyStateChange != null + ? (controller, ajaxRequest) => + onAjaxReadyStateChange.call(controller, ajaxRequest) + : null, + onAjaxProgress: onAjaxProgress != null + ? (controller, ajaxRequest) => + onAjaxProgress.call(controller, ajaxRequest) + : null, + shouldInterceptFetchRequest: shouldInterceptFetchRequest != null + ? (controller, fetchRequest) => + shouldInterceptFetchRequest.call(controller, fetchRequest) + : null, + onUpdateVisitedHistory: onUpdateVisitedHistory != null + ? (controller, url, isReload) => + onUpdateVisitedHistory.call(controller, url, isReload) + : null, + onPrint: onPrint != null + ? (controller, url) => onPrint.call(controller, url) + : null, + onPrintRequest: onPrintRequest != null + ? (controller, url, printJobController) => + onPrintRequest.call(controller, url, printJobController) + : null, + onLongPressHitTestResult: onLongPressHitTestResult != null + ? (controller, hitTestResult) => + onLongPressHitTestResult.call(controller, hitTestResult) + : null, + onEnterFullscreen: onEnterFullscreen != null + ? (controller) => onEnterFullscreen.call(controller) + : null, + onExitFullscreen: onExitFullscreen != null + ? (controller) => onExitFullscreen.call(controller) + : null, + onPageCommitVisible: onPageCommitVisible != null + ? (controller, url) => onPageCommitVisible.call(controller, url) + : null, + onTitleChanged: onTitleChanged != null + ? (controller, title) => onTitleChanged.call(controller, title) + : null, + onWindowFocus: onWindowFocus != null + ? (controller) => onWindowFocus.call(controller) + : null, + onWindowBlur: onWindowBlur != null + ? (controller) => onWindowBlur.call(controller) + : null, + onOverScrolled: onOverScrolled != null + ? (controller, x, y, clampedX, clampedY) => + onOverScrolled.call(controller, x, y, clampedX, clampedY) + : null, + onZoomScaleChanged: onZoomScaleChanged != null + ? (controller, oldScale, newScale) => + onZoomScaleChanged.call(controller, oldScale, newScale) + : null, + androidOnSafeBrowsingHit: androidOnSafeBrowsingHit != null + ? (controller, url, threatType) => + androidOnSafeBrowsingHit.call(controller, url, threatType) + : null, + onSafeBrowsingHit: onSafeBrowsingHit != null + ? (controller, url, threatType) => + onSafeBrowsingHit.call(controller, url, threatType) + : null, + androidOnPermissionRequest: androidOnPermissionRequest != null + ? (controller, origin, resources) => + androidOnPermissionRequest.call(controller, origin, resources) + : null, + onPermissionRequest: onPermissionRequest != null + ? (controller, permissionRequest) => + onPermissionRequest.call(controller, permissionRequest) + : null, androidOnGeolocationPermissionsShowPrompt: - androidOnGeolocationPermissionsShowPrompt, + androidOnGeolocationPermissionsShowPrompt != null + ? (controller, origin) => + androidOnGeolocationPermissionsShowPrompt.call( + controller, origin) + : null, onGeolocationPermissionsShowPrompt: - onGeolocationPermissionsShowPrompt, + onGeolocationPermissionsShowPrompt != null + ? (controller, origin) => onGeolocationPermissionsShowPrompt + .call(controller, origin) + : null, androidOnGeolocationPermissionsHidePrompt: - androidOnGeolocationPermissionsHidePrompt, + androidOnGeolocationPermissionsHidePrompt != null + ? (controller) => + androidOnGeolocationPermissionsHidePrompt.call(controller) + : null, onGeolocationPermissionsHidePrompt: - onGeolocationPermissionsHidePrompt, - androidShouldInterceptRequest: androidShouldInterceptRequest, - shouldInterceptRequest: shouldInterceptRequest, - androidOnRenderProcessGone: androidOnRenderProcessGone, - onRenderProcessGone: onRenderProcessGone, - androidOnRenderProcessResponsive: androidOnRenderProcessResponsive, - onRenderProcessResponsive: onRenderProcessResponsive, + onGeolocationPermissionsHidePrompt != null + ? (controller) => + onGeolocationPermissionsHidePrompt.call(controller) + : null, + androidShouldInterceptRequest: androidShouldInterceptRequest != null + ? (controller, request) => + androidShouldInterceptRequest.call(controller, request) + : null, + shouldInterceptRequest: shouldInterceptRequest != null + ? (controller, request) => + shouldInterceptRequest.call(controller, request) + : null, + androidOnRenderProcessGone: androidOnRenderProcessGone != null + ? (controller, detail) => + androidOnRenderProcessGone.call(controller, detail) + : null, + onRenderProcessGone: onRenderProcessGone != null + ? (controller, detail) => + onRenderProcessGone.call(controller, detail) + : null, + androidOnRenderProcessResponsive: + androidOnRenderProcessResponsive != null + ? (controller, url) => + androidOnRenderProcessResponsive.call(controller, url) + : null, + onRenderProcessResponsive: onRenderProcessResponsive != null + ? (controller, url) => + onRenderProcessResponsive.call(controller, url) + : null, androidOnRenderProcessUnresponsive: - androidOnRenderProcessUnresponsive, - onRenderProcessUnresponsive: onRenderProcessUnresponsive, - androidOnFormResubmission: androidOnFormResubmission, - onFormResubmission: onFormResubmission, - androidOnScaleChanged: androidOnScaleChanged, - androidOnReceivedIcon: androidOnReceivedIcon, - onReceivedIcon: onReceivedIcon, - androidOnReceivedTouchIconUrl: androidOnReceivedTouchIconUrl, - onReceivedTouchIconUrl: onReceivedTouchIconUrl, - androidOnJsBeforeUnload: androidOnJsBeforeUnload, - onJsBeforeUnload: onJsBeforeUnload, - androidOnReceivedLoginRequest: androidOnReceivedLoginRequest, - onReceivedLoginRequest: onReceivedLoginRequest, - onPermissionRequestCanceled: onPermissionRequestCanceled, - onRequestFocus: onRequestFocus, + androidOnRenderProcessUnresponsive != null + ? (controller, url) => + androidOnRenderProcessUnresponsive.call(controller, url) + : null, + onRenderProcessUnresponsive: onRenderProcessUnresponsive != null + ? (controller, url) => + onRenderProcessUnresponsive.call(controller, url) + : null, + androidOnFormResubmission: androidOnFormResubmission != null + ? (controller, url) => + androidOnFormResubmission.call(controller, url) + : null, + onFormResubmission: onFormResubmission != null + ? (controller, url) => onFormResubmission.call(controller, url) + : null, + androidOnScaleChanged: androidOnScaleChanged != null + ? (controller, oldScale, newScale) => + androidOnScaleChanged.call(controller, oldScale, newScale) + : null, + androidOnReceivedIcon: androidOnReceivedIcon != null + ? (controller, icon) => + androidOnReceivedIcon.call(controller, icon) + : null, + onReceivedIcon: onReceivedIcon != null + ? (controller, icon) => onReceivedIcon.call(controller, icon) + : null, + androidOnReceivedTouchIconUrl: androidOnReceivedTouchIconUrl != null + ? (controller, url, precomposed) => androidOnReceivedTouchIconUrl + .call(controller, url, precomposed) + : null, + onReceivedTouchIconUrl: onReceivedTouchIconUrl != null + ? (controller, url, precomposed) => + onReceivedTouchIconUrl.call(controller, url, precomposed) + : null, + androidOnJsBeforeUnload: androidOnJsBeforeUnload != null + ? (controller, jsBeforeUnloadRequest) => androidOnJsBeforeUnload + .call(controller, jsBeforeUnloadRequest) + : null, + onJsBeforeUnload: onJsBeforeUnload != null + ? (controller, jsBeforeUnloadRequest) => + onJsBeforeUnload.call(controller, jsBeforeUnloadRequest) + : null, + androidOnReceivedLoginRequest: androidOnReceivedLoginRequest != null + ? (controller, loginRequest) => + androidOnReceivedLoginRequest.call(controller, loginRequest) + : null, + onReceivedLoginRequest: onReceivedLoginRequest != null + ? (controller, loginRequest) => + onReceivedLoginRequest.call(controller, loginRequest) + : null, + onPermissionRequestCanceled: onPermissionRequestCanceled != null + ? (controller, permissionRequest) => onPermissionRequestCanceled + .call(controller, permissionRequest) + : null, + onRequestFocus: onRequestFocus != null + ? (controller) => onRequestFocus.call(controller) + : null, iosOnWebContentProcessDidTerminate: - iosOnWebContentProcessDidTerminate, - onWebContentProcessDidTerminate: onWebContentProcessDidTerminate, + iosOnWebContentProcessDidTerminate != null + ? (controller) => + iosOnWebContentProcessDidTerminate.call(controller) + : null, + onWebContentProcessDidTerminate: onWebContentProcessDidTerminate != + null + ? (controller) => onWebContentProcessDidTerminate.call(controller) + : null, iosOnDidReceiveServerRedirectForProvisionalNavigation: - iosOnDidReceiveServerRedirectForProvisionalNavigation, + iosOnDidReceiveServerRedirectForProvisionalNavigation != null + ? (controller) => + iosOnDidReceiveServerRedirectForProvisionalNavigation + .call(controller) + : null, onDidReceiveServerRedirectForProvisionalNavigation: - onDidReceiveServerRedirectForProvisionalNavigation, - iosOnNavigationResponse: iosOnNavigationResponse, - onNavigationResponse: onNavigationResponse, - iosShouldAllowDeprecatedTLS: iosShouldAllowDeprecatedTLS, - shouldAllowDeprecatedTLS: shouldAllowDeprecatedTLS, - onCameraCaptureStateChanged: onCameraCaptureStateChanged, - onMicrophoneCaptureStateChanged: onMicrophoneCaptureStateChanged, - onContentSizeChanged: onContentSizeChanged, + onDidReceiveServerRedirectForProvisionalNavigation != null + ? (controller) => + onDidReceiveServerRedirectForProvisionalNavigation + .call(controller) + : null, + iosOnNavigationResponse: iosOnNavigationResponse != null + ? (controller, navigationResponse) => + iosOnNavigationResponse.call(controller, navigationResponse) + : null, + onNavigationResponse: onNavigationResponse != null + ? (controller, navigationResponse) => + onNavigationResponse.call(controller, navigationResponse) + : null, + iosShouldAllowDeprecatedTLS: iosShouldAllowDeprecatedTLS != null + ? (controller, challenge) => + iosShouldAllowDeprecatedTLS.call(controller, challenge) + : null, + shouldAllowDeprecatedTLS: shouldAllowDeprecatedTLS != null + ? (controller, challenge) => + shouldAllowDeprecatedTLS.call(controller, challenge) + : null, + onCameraCaptureStateChanged: onCameraCaptureStateChanged != null + ? (controller, oldState, newState) => onCameraCaptureStateChanged + .call(controller, oldState, newState) + : null, + onMicrophoneCaptureStateChanged: + onMicrophoneCaptureStateChanged != null + ? (controller, oldState, newState) => + onMicrophoneCaptureStateChanged.call( + controller, oldState, newState) + : null, + onContentSizeChanged: onContentSizeChanged != null + ? (controller, oldContentSize, newContentSize) => + onContentSizeChanged.call( + controller, oldContentSize, newContentSize) + : null, )); ///Runs the headless WebView. diff --git a/lib/src/in_app_webview/in_app_webview.dart b/lib/src/in_app_webview/in_app_webview.dart index 09df8298..ebcd6fef 100755 --- a/lib/src/in_app_webview/in_app_webview.dart +++ b/lib/src/in_app_webview/in_app_webview.dart @@ -10,6 +10,7 @@ import 'package:flutter/widgets.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; import 'headless_in_app_webview.dart'; +import 'in_app_webview_controller.dart'; import '../find_interaction/find_interaction_controller.dart'; import '../pull_to_refresh/main.dart'; import '../pull_to_refresh/pull_to_refresh_controller.dart'; @@ -47,21 +48,22 @@ class InAppWebView extends StatefulWidget { HeadlessInAppWebView? headlessWebView, InAppWebViewKeepAlive? keepAlive, bool? preventGestureDelay, + TextDirection? layoutDirection, @Deprecated('Use onGeolocationPermissionsHidePrompt instead') - void Function(PlatformInAppWebViewController controller)? + void Function(InAppWebViewController controller)? androidOnGeolocationPermissionsHidePrompt, @Deprecated('Use onGeolocationPermissionsShowPrompt instead') Future Function( - PlatformInAppWebViewController controller, String origin)? + InAppWebViewController controller, String origin)? androidOnGeolocationPermissionsShowPrompt, @Deprecated('Use onPermissionRequest instead') Future Function( - PlatformInAppWebViewController controller, + InAppWebViewController controller, String origin, List resources)? androidOnPermissionRequest, @Deprecated('Use onSafeBrowsingHit instead') - Future Function(PlatformInAppWebViewController controller, + Future Function(InAppWebViewController controller, Uri url, SafeBrowsingThreat? threatType)? androidOnSafeBrowsingHit, InAppWebViewInitialData? initialData, @@ -74,232 +76,235 @@ class InAppWebView extends StatefulWidget { PullToRefreshController? pullToRefreshController, FindInteractionController? findInteractionController, ContextMenu? contextMenu, - void Function(PlatformInAppWebViewController controller, WebUri? url)? + void Function(InAppWebViewController controller, WebUri? url)? onPageCommitVisible, - void Function(PlatformInAppWebViewController controller, String? title)? + void Function(InAppWebViewController controller, String? title)? onTitleChanged, @Deprecated( 'Use onDidReceiveServerRedirectForProvisionalNavigation instead') - void Function(PlatformInAppWebViewController controller)? + void Function(InAppWebViewController controller)? iosOnDidReceiveServerRedirectForProvisionalNavigation, @Deprecated('Use onWebContentProcessDidTerminate instead') - void Function(PlatformInAppWebViewController controller)? + void Function(InAppWebViewController controller)? iosOnWebContentProcessDidTerminate, @Deprecated('Use onNavigationResponse instead') Future Function( - PlatformInAppWebViewController controller, + InAppWebViewController controller, IOSWKNavigationResponse navigationResponse)? iosOnNavigationResponse, @Deprecated('Use shouldAllowDeprecatedTLS instead') Future Function( - PlatformInAppWebViewController controller, + InAppWebViewController controller, URLAuthenticationChallenge challenge)? iosShouldAllowDeprecatedTLS, Future Function( - PlatformInAppWebViewController controller, AjaxRequest ajaxRequest)? + InAppWebViewController controller, AjaxRequest ajaxRequest)? onAjaxProgress, Future Function( - PlatformInAppWebViewController controller, AjaxRequest ajaxRequest)? + InAppWebViewController controller, AjaxRequest ajaxRequest)? onAjaxReadyStateChange, void Function( - PlatformInAppWebViewController controller, ConsoleMessage consoleMessage)? + InAppWebViewController controller, ConsoleMessage consoleMessage)? onConsoleMessage, - Future Function(PlatformInAppWebViewController controller, + Future Function(InAppWebViewController controller, CreateWindowAction createWindowAction)? onCreateWindow, - void Function(PlatformInAppWebViewController controller)? onCloseWindow, - void Function(PlatformInAppWebViewController controller)? onWindowFocus, - void Function(PlatformInAppWebViewController controller)? onWindowBlur, + void Function(InAppWebViewController controller)? onCloseWindow, + void Function(InAppWebViewController controller)? onWindowFocus, + void Function(InAppWebViewController controller)? onWindowBlur, @Deprecated('Use onReceivedIcon instead') - void Function(PlatformInAppWebViewController controller, Uint8List icon)? + void Function(InAppWebViewController controller, Uint8List icon)? androidOnReceivedIcon, @Deprecated('Use onReceivedTouchIconUrl instead') - void Function(PlatformInAppWebViewController controller, Uri url, bool precomposed)? + void Function(InAppWebViewController controller, Uri url, bool precomposed)? androidOnReceivedTouchIconUrl, @Deprecated('Use onDownloadStartRequest instead') - void Function(PlatformInAppWebViewController controller, Uri url)? onDownloadStart, - void Function(PlatformInAppWebViewController controller, + void Function(InAppWebViewController controller, Uri url)? onDownloadStart, + void Function(InAppWebViewController controller, DownloadStartRequest downloadStartRequest)? onDownloadStartRequest, @Deprecated('Use FindInteractionController.onFindResultReceived instead') - void Function(PlatformInAppWebViewController controller, int activeMatchOrdinal, + void Function(InAppWebViewController controller, int activeMatchOrdinal, int numberOfMatches, bool isDoneCounting)? onFindResultReceived, Future Function( - PlatformInAppWebViewController controller, JsAlertRequest jsAlertRequest)? + InAppWebViewController controller, JsAlertRequest jsAlertRequest)? onJsAlert, - Future Function(PlatformInAppWebViewController controller, + Future Function(InAppWebViewController controller, JsConfirmRequest jsConfirmRequest)? onJsConfirm, Future Function( - PlatformInAppWebViewController controller, JsPromptRequest jsPromptRequest)? + InAppWebViewController controller, JsPromptRequest jsPromptRequest)? onJsPrompt, @Deprecated("Use onReceivedError instead") - void Function(PlatformInAppWebViewController controller, Uri? url, int code, + void Function(InAppWebViewController controller, Uri? url, int code, String message)? onLoadError, - void Function(PlatformInAppWebViewController controller, WebResourceRequest request, + void Function(InAppWebViewController controller, WebResourceRequest request, WebResourceError error)? onReceivedError, @Deprecated("Use onReceivedHttpError instead") - void Function(PlatformInAppWebViewController controller, Uri? url, int statusCode, + void Function(InAppWebViewController controller, Uri? url, int statusCode, String description)? onLoadHttpError, - void Function(PlatformInAppWebViewController controller, WebResourceRequest request, + void Function(InAppWebViewController controller, WebResourceRequest request, WebResourceResponse errorResponse)? onReceivedHttpError, - void Function(PlatformInAppWebViewController controller, LoadedResource resource)? + void Function(InAppWebViewController controller, LoadedResource resource)? onLoadResource, @Deprecated('Use onLoadResourceWithCustomScheme instead') Future Function( - PlatformInAppWebViewController controller, Uri url)? + InAppWebViewController controller, Uri url)? onLoadResourceCustomScheme, Future Function( - PlatformInAppWebViewController controller, WebResourceRequest request)? + InAppWebViewController controller, WebResourceRequest request)? onLoadResourceWithCustomScheme, - void Function(PlatformInAppWebViewController controller, WebUri? url)? onLoadStart, - void Function(PlatformInAppWebViewController controller, WebUri? url)? onLoadStop, - void Function(PlatformInAppWebViewController controller, + void Function(InAppWebViewController controller, WebUri? url)? onLoadStart, + void Function(InAppWebViewController controller, WebUri? url)? onLoadStop, + void Function(InAppWebViewController controller, InAppWebViewHitTestResult hitTestResult)? onLongPressHitTestResult, @Deprecated("Use onPrintRequest instead") - void Function(PlatformInAppWebViewController controller, Uri? url)? onPrint, - Future Function(PlatformInAppWebViewController controller, WebUri? url, - PlatformPrintJobController? printJobController)? + void Function(InAppWebViewController controller, Uri? url)? onPrint, + Future Function(InAppWebViewController controller, WebUri? url, + PlatformPrintJobController? printJobController)? onPrintRequest, - void Function(PlatformInAppWebViewController controller, int progress)? + void Function(InAppWebViewController controller, int progress)? onProgressChanged, - Future Function(PlatformInAppWebViewController controller, + Future Function(InAppWebViewController controller, URLAuthenticationChallenge challenge)? onReceivedClientCertRequest, - Future Function(PlatformInAppWebViewController controller, + Future Function(InAppWebViewController controller, URLAuthenticationChallenge challenge)? onReceivedHttpAuthRequest, - Future Function(PlatformInAppWebViewController controller, + Future Function(InAppWebViewController controller, URLAuthenticationChallenge challenge)? onReceivedServerTrustAuthRequest, - void Function(PlatformInAppWebViewController controller, int x, int y)? + void Function(InAppWebViewController controller, int x, int y)? onScrollChanged, void Function( - PlatformInAppWebViewController controller, WebUri? url, bool? isReload)? + InAppWebViewController controller, WebUri? url, bool? isReload)? onUpdateVisitedHistory, - void Function(PlatformInAppWebViewController controller)? onWebViewCreated, + void Function(InAppWebViewController controller)? onWebViewCreated, Future Function( - PlatformInAppWebViewController controller, AjaxRequest ajaxRequest)? + InAppWebViewController controller, AjaxRequest ajaxRequest)? shouldInterceptAjaxRequest, Future Function( - PlatformInAppWebViewController controller, FetchRequest fetchRequest)? + InAppWebViewController controller, FetchRequest fetchRequest)? shouldInterceptFetchRequest, - Future Function(PlatformInAppWebViewController controller, + Future Function(InAppWebViewController controller, NavigationAction navigationAction)? shouldOverrideUrlLoading, - void Function(PlatformInAppWebViewController controller)? onEnterFullscreen, - void Function(PlatformInAppWebViewController controller)? onExitFullscreen, - void Function(PlatformInAppWebViewController controller, int x, int y, + void Function(InAppWebViewController controller)? onEnterFullscreen, + void Function(InAppWebViewController controller)? onExitFullscreen, + void Function(InAppWebViewController controller, int x, int y, bool clampedX, bool clampedY)? onOverScrolled, - void Function(PlatformInAppWebViewController controller, double oldScale, + void Function(InAppWebViewController controller, double oldScale, double newScale)? onZoomScaleChanged, @Deprecated('Use shouldInterceptRequest instead') Future Function( - PlatformInAppWebViewController controller, WebResourceRequest request)? + InAppWebViewController controller, WebResourceRequest request)? androidShouldInterceptRequest, @Deprecated('Use onRenderProcessUnresponsive instead') Future Function( - PlatformInAppWebViewController controller, Uri? url)? + InAppWebViewController controller, Uri? url)? androidOnRenderProcessUnresponsive, @Deprecated('Use onRenderProcessResponsive instead') Future Function( - PlatformInAppWebViewController controller, Uri? url)? + InAppWebViewController controller, Uri? url)? androidOnRenderProcessResponsive, @Deprecated('Use onRenderProcessGone instead') void Function( - PlatformInAppWebViewController controller, RenderProcessGoneDetail detail)? + InAppWebViewController controller, RenderProcessGoneDetail detail)? androidOnRenderProcessGone, @Deprecated('Use onFormResubmission instead') Future Function( - PlatformInAppWebViewController controller, Uri? url)? + InAppWebViewController controller, Uri? url)? androidOnFormResubmission, @Deprecated('Use onZoomScaleChanged instead') - void Function(PlatformInAppWebViewController controller, double oldScale, + void Function(InAppWebViewController controller, double oldScale, double newScale)? androidOnScaleChanged, @Deprecated('Use onJsBeforeUnload instead') - Future Function(PlatformInAppWebViewController controller, + Future Function(InAppWebViewController controller, JsBeforeUnloadRequest jsBeforeUnloadRequest)? androidOnJsBeforeUnload, @Deprecated('Use onReceivedLoginRequest instead') - void Function(PlatformInAppWebViewController controller, LoginRequest loginRequest)? + void Function(InAppWebViewController controller, LoginRequest loginRequest)? androidOnReceivedLoginRequest, - void Function(PlatformInAppWebViewController controller)? + void Function(InAppWebViewController controller)? onDidReceiveServerRedirectForProvisionalNavigation, Future Function( - PlatformInAppWebViewController controller, WebUri? url)? + InAppWebViewController controller, WebUri? url)? onFormResubmission, - void Function(PlatformInAppWebViewController controller)? + void Function(InAppWebViewController controller)? onGeolocationPermissionsHidePrompt, Future Function( - PlatformInAppWebViewController controller, String origin)? + InAppWebViewController controller, String origin)? onGeolocationPermissionsShowPrompt, - Future Function(PlatformInAppWebViewController controller, + Future Function(InAppWebViewController controller, JsBeforeUnloadRequest jsBeforeUnloadRequest)? onJsBeforeUnload, Future Function( - PlatformInAppWebViewController controller, + InAppWebViewController controller, NavigationResponse navigationResponse)? onNavigationResponse, - Future Function(PlatformInAppWebViewController controller, + Future Function(InAppWebViewController controller, PermissionRequest permissionRequest)? onPermissionRequest, - void Function(PlatformInAppWebViewController controller, Uint8List icon)? + void Function(InAppWebViewController controller, Uint8List icon)? onReceivedIcon, - void Function(PlatformInAppWebViewController controller, LoginRequest loginRequest)? + void Function(InAppWebViewController controller, LoginRequest loginRequest)? onReceivedLoginRequest, - void Function(PlatformInAppWebViewController controller, + void Function(InAppWebViewController controller, PermissionRequest permissionRequest)? onPermissionRequestCanceled, - void Function(PlatformInAppWebViewController controller)? onRequestFocus, + void Function(InAppWebViewController controller)? onRequestFocus, void Function( - PlatformInAppWebViewController controller, WebUri url, bool precomposed)? + InAppWebViewController controller, WebUri url, bool precomposed)? onReceivedTouchIconUrl, void Function( - PlatformInAppWebViewController controller, RenderProcessGoneDetail detail)? + InAppWebViewController controller, RenderProcessGoneDetail detail)? onRenderProcessGone, Future Function( - PlatformInAppWebViewController controller, WebUri? url)? + InAppWebViewController controller, WebUri? url)? onRenderProcessResponsive, Future Function( - PlatformInAppWebViewController controller, WebUri? url)? + InAppWebViewController controller, WebUri? url)? onRenderProcessUnresponsive, - Future Function(PlatformInAppWebViewController controller, + Future Function(InAppWebViewController controller, WebUri url, SafeBrowsingThreat? threatType)? onSafeBrowsingHit, - void Function(PlatformInAppWebViewController controller)? + void Function(InAppWebViewController controller)? onWebContentProcessDidTerminate, Future Function( - PlatformInAppWebViewController controller, + InAppWebViewController controller, URLAuthenticationChallenge challenge)? shouldAllowDeprecatedTLS, Future Function( - PlatformInAppWebViewController controller, WebResourceRequest request)? + InAppWebViewController controller, WebResourceRequest request)? shouldInterceptRequest, Future Function( - PlatformInAppWebViewController controller, + InAppWebViewController controller, MediaCaptureState? oldState, MediaCaptureState? newState, )? onCameraCaptureStateChanged, Future Function( - PlatformInAppWebViewController controller, + InAppWebViewController controller, MediaCaptureState? oldState, MediaCaptureState? newState, )? onMicrophoneCaptureStateChanged, - void Function(PlatformInAppWebViewController controller, Size oldContentSize, + void Function(InAppWebViewController controller, Size oldContentSize, Size newContentSize)? onContentSizeChanged, }) : this.fromPlatformCreationParams( key: key, params: PlatformInAppWebViewWidgetCreationParams( + controllerFromPlatform: + (PlatformInAppWebViewController controller) => + InAppWebViewController.fromPlatform(platform: controller), windowId: windowId, keepAlive: keepAlive, initialUrlRequest: initialUrlRequest, @@ -311,97 +316,350 @@ class InAppWebView extends StatefulWidget { pullToRefreshController: pullToRefreshController?.platform, findInteractionController: findInteractionController?.platform, contextMenu: contextMenu, - onWebViewCreated: onWebViewCreated, - onLoadStart: onLoadStart, - onLoadStop: onLoadStop, - onLoadError: onLoadError, - onReceivedError: onReceivedError, - onLoadHttpError: onLoadHttpError, - onReceivedHttpError: onReceivedHttpError, - onConsoleMessage: onConsoleMessage, - onProgressChanged: onProgressChanged, - shouldOverrideUrlLoading: shouldOverrideUrlLoading, - onLoadResource: onLoadResource, - onScrollChanged: onScrollChanged, - onDownloadStart: onDownloadStart, - onDownloadStartRequest: onDownloadStartRequest, - onLoadResourceCustomScheme: onLoadResourceCustomScheme, - onLoadResourceWithCustomScheme: onLoadResourceWithCustomScheme, - onCreateWindow: onCreateWindow, - onCloseWindow: onCloseWindow, - onJsAlert: onJsAlert, - onJsConfirm: onJsConfirm, - onJsPrompt: onJsPrompt, - onReceivedHttpAuthRequest: onReceivedHttpAuthRequest, + layoutDirection: layoutDirection, + onWebViewCreated: onWebViewCreated != null + ? (controller) => onWebViewCreated.call(controller) + : null, + onLoadStart: onLoadStart != null + ? (controller, url) => onLoadStart.call(controller, url) + : null, + onLoadStop: onLoadStop != null + ? (controller, url) => onLoadStop.call(controller, url) + : null, + onLoadError: onLoadError != null + ? (controller, url, code, message) => + onLoadError.call(controller, url, code, message) + : null, + onReceivedError: onReceivedError != null + ? (controller, request, error) => + onReceivedError.call(controller, request, error) + : null, + onLoadHttpError: onLoadHttpError != null + ? (controller, url, statusCode, description) => + onLoadHttpError.call( + controller, url, statusCode, description) + : null, + onReceivedHttpError: onReceivedHttpError != null + ? (controller, request, errorResponse) => onReceivedHttpError + .call(controller, request, errorResponse) + : null, + onConsoleMessage: onConsoleMessage != null + ? (controller, consoleMessage) => + onConsoleMessage.call(controller, consoleMessage) + : null, + onProgressChanged: onProgressChanged != null + ? (controller, progress) => + onProgressChanged.call(controller, progress) + : null, + shouldOverrideUrlLoading: shouldOverrideUrlLoading != null + ? (controller, navigationAction) => + shouldOverrideUrlLoading(controller, navigationAction) + : null, + onLoadResource: onLoadResource != null + ? (controller, resource) => + onLoadResource.call(controller, resource) + : null, + onScrollChanged: onScrollChanged != null + ? (controller, x, y) => onScrollChanged.call(controller, x, y) + : null, + onDownloadStart: onDownloadStart != null + ? (controller, url) => onDownloadStart.call(controller, url) + : null, + onDownloadStartRequest: onDownloadStartRequest != null + ? (controller, downloadStartRequest) => onDownloadStartRequest + .call(controller, downloadStartRequest) + : null, + onLoadResourceCustomScheme: onLoadResourceCustomScheme != null + ? (controller, url) => + onLoadResourceCustomScheme.call(controller, url) + : null, + onLoadResourceWithCustomScheme: onLoadResourceWithCustomScheme != + null + ? (controller, request) => + onLoadResourceWithCustomScheme.call(controller, request) + : null, + onCreateWindow: onCreateWindow != null + ? (controller, createWindowAction) => + onCreateWindow.call(controller, createWindowAction) + : null, + onCloseWindow: onCloseWindow != null + ? (controller) => onCloseWindow.call(controller) + : null, + onJsAlert: onJsAlert != null + ? (controller, jsAlertRequest) => + onJsAlert.call(controller, jsAlertRequest) + : null, + onJsConfirm: onJsConfirm != null + ? (controller, jsConfirmRequest) => + onJsConfirm.call(controller, jsConfirmRequest) + : null, + onJsPrompt: onJsPrompt != null + ? (controller, jsPromptRequest) => + onJsPrompt.call(controller, jsPromptRequest) + : null, + onReceivedHttpAuthRequest: onReceivedHttpAuthRequest != null + ? (controller, challenge) => + onReceivedHttpAuthRequest.call(controller, challenge) + : null, onReceivedServerTrustAuthRequest: - onReceivedServerTrustAuthRequest, - onReceivedClientCertRequest: onReceivedClientCertRequest, - onFindResultReceived: onFindResultReceived, - shouldInterceptAjaxRequest: shouldInterceptAjaxRequest, - onAjaxReadyStateChange: onAjaxReadyStateChange, - onAjaxProgress: onAjaxProgress, - shouldInterceptFetchRequest: shouldInterceptFetchRequest, - onUpdateVisitedHistory: onUpdateVisitedHistory, - onPrint: onPrint, - onPrintRequest: onPrintRequest, - onLongPressHitTestResult: onLongPressHitTestResult, - onEnterFullscreen: onEnterFullscreen, - onExitFullscreen: onExitFullscreen, - onPageCommitVisible: onPageCommitVisible, - onTitleChanged: onTitleChanged, - onWindowFocus: onWindowFocus, - onWindowBlur: onWindowBlur, - onOverScrolled: onOverScrolled, - onZoomScaleChanged: onZoomScaleChanged, - androidOnSafeBrowsingHit: androidOnSafeBrowsingHit, - onSafeBrowsingHit: onSafeBrowsingHit, - androidOnPermissionRequest: androidOnPermissionRequest, - onPermissionRequest: onPermissionRequest, + onReceivedServerTrustAuthRequest != null + ? (controller, challenge) => + onReceivedServerTrustAuthRequest.call( + controller, challenge) + : null, + onReceivedClientCertRequest: onReceivedClientCertRequest != null + ? (controller, challenge) => + onReceivedClientCertRequest.call(controller, challenge) + : null, + onFindResultReceived: onFindResultReceived != null + ? (controller, activeMatchOrdinal, numberOfMatches, + isDoneCounting) => + onFindResultReceived.call(controller, activeMatchOrdinal, + numberOfMatches, isDoneCounting) + : null, + shouldInterceptAjaxRequest: shouldInterceptAjaxRequest != null + ? (controller, ajaxRequest) => + shouldInterceptAjaxRequest.call(controller, ajaxRequest) + : null, + onAjaxReadyStateChange: onAjaxReadyStateChange != null + ? (controller, ajaxRequest) => + onAjaxReadyStateChange.call(controller, ajaxRequest) + : null, + onAjaxProgress: onAjaxProgress != null + ? (controller, ajaxRequest) => + onAjaxProgress.call(controller, ajaxRequest) + : null, + shouldInterceptFetchRequest: shouldInterceptFetchRequest != null + ? (controller, fetchRequest) => + shouldInterceptFetchRequest.call(controller, fetchRequest) + : null, + onUpdateVisitedHistory: onUpdateVisitedHistory != null + ? (controller, url, isReload) => + onUpdateVisitedHistory.call(controller, url, isReload) + : null, + onPrint: onPrint != null + ? (controller, url) => onPrint.call(controller, url) + : null, + onPrintRequest: onPrintRequest != null + ? (controller, url, printJobController) => + onPrintRequest.call(controller, url, printJobController) + : null, + onLongPressHitTestResult: onLongPressHitTestResult != null + ? (controller, hitTestResult) => + onLongPressHitTestResult.call(controller, hitTestResult) + : null, + onEnterFullscreen: onEnterFullscreen != null + ? (controller) => onEnterFullscreen.call(controller) + : null, + onExitFullscreen: onExitFullscreen != null + ? (controller) => onExitFullscreen.call(controller) + : null, + onPageCommitVisible: onPageCommitVisible != null + ? (controller, url) => + onPageCommitVisible.call(controller, url) + : null, + onTitleChanged: onTitleChanged != null + ? (controller, title) => + onTitleChanged.call(controller, title) + : null, + onWindowFocus: onWindowFocus != null + ? (controller) => onWindowFocus.call(controller) + : null, + onWindowBlur: onWindowBlur != null + ? (controller) => onWindowBlur.call(controller) + : null, + onOverScrolled: onOverScrolled != null + ? (controller, x, y, clampedX, clampedY) => + onOverScrolled.call(controller, x, y, clampedX, clampedY) + : null, + onZoomScaleChanged: onZoomScaleChanged != null + ? (controller, oldScale, newScale) => + onZoomScaleChanged.call(controller, oldScale, newScale) + : null, + androidOnSafeBrowsingHit: androidOnSafeBrowsingHit != null + ? (controller, url, threatType) => + androidOnSafeBrowsingHit.call(controller, url, threatType) + : null, + onSafeBrowsingHit: onSafeBrowsingHit != null + ? (controller, url, threatType) => + onSafeBrowsingHit.call(controller, url, threatType) + : null, + androidOnPermissionRequest: androidOnPermissionRequest != null + ? (controller, origin, resources) => + androidOnPermissionRequest.call( + controller, origin, resources) + : null, + onPermissionRequest: onPermissionRequest != null + ? (controller, permissionRequest) => + onPermissionRequest.call(controller, permissionRequest) + : null, androidOnGeolocationPermissionsShowPrompt: - androidOnGeolocationPermissionsShowPrompt, + androidOnGeolocationPermissionsShowPrompt != null + ? (controller, origin) => + androidOnGeolocationPermissionsShowPrompt.call( + controller, origin) + : null, onGeolocationPermissionsShowPrompt: - onGeolocationPermissionsShowPrompt, + onGeolocationPermissionsShowPrompt != null + ? (controller, origin) => + onGeolocationPermissionsShowPrompt.call( + controller, origin) + : null, androidOnGeolocationPermissionsHidePrompt: - androidOnGeolocationPermissionsHidePrompt, + androidOnGeolocationPermissionsHidePrompt != null + ? (controller) => + androidOnGeolocationPermissionsHidePrompt + .call(controller) + : null, onGeolocationPermissionsHidePrompt: - onGeolocationPermissionsHidePrompt, - androidShouldInterceptRequest: androidShouldInterceptRequest, - shouldInterceptRequest: shouldInterceptRequest, - androidOnRenderProcessGone: androidOnRenderProcessGone, - onRenderProcessGone: onRenderProcessGone, + onGeolocationPermissionsHidePrompt != null + ? (controller) => + onGeolocationPermissionsHidePrompt.call(controller) + : null, + androidShouldInterceptRequest: androidShouldInterceptRequest != + null + ? (controller, request) => + androidShouldInterceptRequest.call(controller, request) + : null, + shouldInterceptRequest: shouldInterceptRequest != null + ? (controller, request) => + shouldInterceptRequest.call(controller, request) + : null, + androidOnRenderProcessGone: androidOnRenderProcessGone != null + ? (controller, detail) => + androidOnRenderProcessGone.call(controller, detail) + : null, + onRenderProcessGone: onRenderProcessGone != null + ? (controller, detail) => + onRenderProcessGone.call(controller, detail) + : null, androidOnRenderProcessResponsive: - androidOnRenderProcessResponsive, - onRenderProcessResponsive: onRenderProcessResponsive, + androidOnRenderProcessResponsive != null + ? (controller, url) => + androidOnRenderProcessResponsive.call(controller, url) + : null, + onRenderProcessResponsive: onRenderProcessResponsive != null + ? (controller, url) => + onRenderProcessResponsive.call(controller, url) + : null, androidOnRenderProcessUnresponsive: - androidOnRenderProcessUnresponsive, - onRenderProcessUnresponsive: onRenderProcessUnresponsive, - androidOnFormResubmission: androidOnFormResubmission, - onFormResubmission: onFormResubmission, - androidOnScaleChanged: androidOnScaleChanged, - androidOnReceivedIcon: androidOnReceivedIcon, - onReceivedIcon: onReceivedIcon, - androidOnReceivedTouchIconUrl: androidOnReceivedTouchIconUrl, - onReceivedTouchIconUrl: onReceivedTouchIconUrl, - androidOnJsBeforeUnload: androidOnJsBeforeUnload, - onJsBeforeUnload: onJsBeforeUnload, - androidOnReceivedLoginRequest: androidOnReceivedLoginRequest, - onReceivedLoginRequest: onReceivedLoginRequest, - onPermissionRequestCanceled: onPermissionRequestCanceled, - onRequestFocus: onRequestFocus, + androidOnRenderProcessUnresponsive != null + ? (controller, url) => androidOnRenderProcessUnresponsive + .call(controller, url) + : null, + onRenderProcessUnresponsive: onRenderProcessUnresponsive != null + ? (controller, url) => + onRenderProcessUnresponsive.call(controller, url) + : null, + androidOnFormResubmission: androidOnFormResubmission != null + ? (controller, url) => + androidOnFormResubmission.call(controller, url) + : null, + onFormResubmission: onFormResubmission != null + ? (controller, url) => + onFormResubmission.call(controller, url) + : null, + androidOnScaleChanged: androidOnScaleChanged != null + ? (controller, oldScale, newScale) => + androidOnScaleChanged.call(controller, oldScale, newScale) + : null, + androidOnReceivedIcon: androidOnReceivedIcon != null + ? (controller, icon) => + androidOnReceivedIcon.call(controller, icon) + : null, + onReceivedIcon: onReceivedIcon != null + ? (controller, icon) => onReceivedIcon.call(controller, icon) + : null, + androidOnReceivedTouchIconUrl: + androidOnReceivedTouchIconUrl != null + ? (controller, url, precomposed) => + androidOnReceivedTouchIconUrl.call( + controller, url, precomposed) + : null, + onReceivedTouchIconUrl: onReceivedTouchIconUrl != null + ? (controller, url, precomposed) => + onReceivedTouchIconUrl.call(controller, url, precomposed) + : null, + androidOnJsBeforeUnload: androidOnJsBeforeUnload != null + ? (controller, jsBeforeUnloadRequest) => + androidOnJsBeforeUnload.call( + controller, jsBeforeUnloadRequest) + : null, + onJsBeforeUnload: onJsBeforeUnload != null + ? (controller, jsBeforeUnloadRequest) => + onJsBeforeUnload.call(controller, jsBeforeUnloadRequest) + : null, + androidOnReceivedLoginRequest: androidOnReceivedLoginRequest != + null + ? (controller, loginRequest) => androidOnReceivedLoginRequest + .call(controller, loginRequest) + : null, + onReceivedLoginRequest: onReceivedLoginRequest != null + ? (controller, loginRequest) => + onReceivedLoginRequest.call(controller, loginRequest) + : null, + onPermissionRequestCanceled: onPermissionRequestCanceled != null + ? (controller, permissionRequest) => + onPermissionRequestCanceled.call( + controller, permissionRequest) + : null, + onRequestFocus: onRequestFocus != null + ? (controller) => onRequestFocus.call(controller) + : null, iosOnWebContentProcessDidTerminate: - iosOnWebContentProcessDidTerminate, - onWebContentProcessDidTerminate: onWebContentProcessDidTerminate, + iosOnWebContentProcessDidTerminate != null + ? (controller) => + iosOnWebContentProcessDidTerminate.call(controller) + : null, + onWebContentProcessDidTerminate: + onWebContentProcessDidTerminate != null + ? (controller) => + onWebContentProcessDidTerminate.call(controller) + : null, iosOnDidReceiveServerRedirectForProvisionalNavigation: - iosOnDidReceiveServerRedirectForProvisionalNavigation, + iosOnDidReceiveServerRedirectForProvisionalNavigation != null + ? (controller) => + iosOnDidReceiveServerRedirectForProvisionalNavigation + .call(controller) + : null, onDidReceiveServerRedirectForProvisionalNavigation: - onDidReceiveServerRedirectForProvisionalNavigation, - iosOnNavigationResponse: iosOnNavigationResponse, - onNavigationResponse: onNavigationResponse, - iosShouldAllowDeprecatedTLS: iosShouldAllowDeprecatedTLS, - shouldAllowDeprecatedTLS: shouldAllowDeprecatedTLS, - onCameraCaptureStateChanged: onCameraCaptureStateChanged, - onMicrophoneCaptureStateChanged: onMicrophoneCaptureStateChanged, - onContentSizeChanged: onContentSizeChanged, + onDidReceiveServerRedirectForProvisionalNavigation != null + ? (controller) => + onDidReceiveServerRedirectForProvisionalNavigation + .call(controller) + : null, + iosOnNavigationResponse: iosOnNavigationResponse != null + ? (controller, navigationResponse) => iosOnNavigationResponse + .call(controller, navigationResponse) + : null, + onNavigationResponse: onNavigationResponse != null + ? (controller, navigationResponse) => + onNavigationResponse.call(controller, navigationResponse) + : null, + iosShouldAllowDeprecatedTLS: iosShouldAllowDeprecatedTLS != null + ? (controller, challenge) => + iosShouldAllowDeprecatedTLS.call(controller, challenge) + : null, + shouldAllowDeprecatedTLS: shouldAllowDeprecatedTLS != null + ? (controller, challenge) => + shouldAllowDeprecatedTLS.call(controller, challenge) + : null, + onCameraCaptureStateChanged: onCameraCaptureStateChanged != null + ? (controller, oldState, newState) => + onCameraCaptureStateChanged.call( + controller, oldState, newState) + : null, + onMicrophoneCaptureStateChanged: + onMicrophoneCaptureStateChanged != null + ? (controller, oldState, newState) => + onMicrophoneCaptureStateChanged.call( + controller, oldState, newState) + : null, + onContentSizeChanged: onContentSizeChanged != null + ? (controller, oldContentSize, newContentSize) => + onContentSizeChanged.call( + controller, oldContentSize, newContentSize) + : null, gestureRecognizers: gestureRecognizers, headlessWebView: headlessWebView?.platform, preventGestureDelay: preventGestureDelay, diff --git a/lib/src/web_message/web_message_port.dart b/lib/src/web_message/web_message_port.dart index 6641b6c6..8b988231 100644 --- a/lib/src/web_message/web_message_port.dart +++ b/lib/src/web_message/web_message_port.dart @@ -18,7 +18,7 @@ import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_pla ///A transferred port cannot be closed by the application, since the ownership is also transferred. /// ///It is possible to transfer both ports of a channel to JavaScript, for example for communication between subframes. -class WebMessagePort { +class WebMessagePort implements IWebMessagePort { WebMessagePort({required int index}) : this.fromPlatformCreationParams( params: PlatformWebMessagePortCreationParams(index: index)); diff --git a/lib/src/webview_asset_loader.dart b/lib/src/webview_asset_loader.dart index b790982e..ac319ab5 100644 --- a/lib/src/webview_asset_loader.dart +++ b/lib/src/webview_asset_loader.dart @@ -1,83 +1,9 @@ import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; -///Helper class to load local files including application's static assets and resources using http(s):// URLs inside a [WebView] class. -///Loading local files using web-like URLs instead of `file://` is desirable as it is compatible with the Same-Origin policy. -/// -///For more context about application's assets and resources and how to normally access them please refer to -///[Android Developer Docs: App resources overview](https://developer.android.com/guide/topics/resources/providing-resources). -/// -///Using http(s):// URLs to access local resources may conflict with a real website. -///This means that local files should only be hosted on domains your organization owns -///(at paths reserved for this purpose) or the default domain reserved for this: `appassets.androidplatform.net`. -/// -///**Supported Platforms/Implementations**: -///- Android native WebView -class WebViewAssetLoader { - /// Constructs a [WebViewAssetLoader]. - /// - /// See [WebViewAssetLoader.fromPlatformCreationParams] for setting - /// parameters for a specific platform. - WebViewAssetLoader( - {String? domain, bool? httpAllowed, List? pathHandlers}) - : this.fromPlatformCreationParams( - params: PlatformWebViewAssetLoaderCreationParams( - domain: domain, - httpAllowed: httpAllowed, - pathHandlers: pathHandlers?.map((e) => e.platform).toList())); - - /// Constructs a [WebViewAssetLoader]. - /// - /// See [WebViewAssetLoader.fromPlatformCreationParams] for setting parameters for - /// a specific platform. - WebViewAssetLoader.fromPlatformCreationParams({ - required PlatformWebViewAssetLoaderCreationParams params, - }) : this.fromPlatform(platform: PlatformWebViewAssetLoader(params)); - - /// Constructs a [WebViewAssetLoader] from a specific platform implementation. - WebViewAssetLoader.fromPlatform({required this.platform}); - - /// Implementation of [PlatformWebViewAssetLoader] for the current platform. - final PlatformWebViewAssetLoader platform; - - ///An unused domain reserved for Android applications to intercept requests for app assets. - /// - ///It is used by default unless the user specified a different domain. - static final String DEFAULT_DOMAIN = - PlatformWebViewAssetLoader.DEFAULT_DOMAIN; - - ///Set the domain under which app assets can be accessed. The default domain is `appassets.androidplatform.net`. - String? get domain => platform.domain; - - ///Allow using the HTTP scheme in addition to HTTPS. The default is to not allow HTTP. - bool? get httpAllowed => platform.httpAllowed; - - ///List of registered path handlers. - /// - ///[WebViewAssetLoader] will try Path Handlers in the order they're registered, - ///and will use whichever is the first to return a non-null. - List? get pathHandlers => platform.pathHandlers - ?.map((platform) { - switch (platform.runtimeType) { - case AssetsPathHandler: - return AssetsPathHandler.fromPlatform( - platform: platform as PlatformAssetsPathHandler); - case ResourcesPathHandler: - return ResourcesPathHandler.fromPlatform( - platform: platform as PlatformResourcesPathHandler); - case InternalStoragePathHandler: - return InternalStoragePathHandler.fromPlatform( - platform: platform as PlatformInternalStoragePathHandler); - } - return null; - }) - .whereType() - .toList(); -} - ///A handler that produces responses for a registered path. /// ///Implement this interface to handle other use-cases according to your app's needs. -abstract class PathHandler implements PlatformPathHandlerEvents { +abstract class PathHandler implements IPathHandler, PlatformPathHandlerEvents { /// Constructs a [PathHandler]. /// /// See [PathHandler.fromPlatformCreationParams] for setting @@ -118,6 +44,12 @@ abstract class PathHandler implements PlatformPathHandlerEvents { Future handle(String path) async { return null; } + + @override + Map toMap() => platform.toMap(); + + @override + Map toJson() => platform.toJson(); } ///Handler class to open a file from assets directory in the application APK. diff --git a/pubspec.yaml b/pubspec.yaml index ead8fe7c..548afb56 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview description: A Flutter plugin that allows you to add an inline webview, to use an headless webview, and to open an in-app browser window. -version: 6.1.0-beta.1 +version: 6.0.0-beta.29 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues