From 1e6de69d208baa3695e5848a68f3dca779b7213e Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Wed, 27 Apr 2022 01:03:42 +0200 Subject: [PATCH] moved every class in types.dart in a specific class file --- .../android/service_worker_controller.dart | 2 +- .../android/chrome_custom_tabs_options.dart | 2 +- .../apple/safari_options.dart | 2 +- .../chrome_safari_browser_settings.dart | 2 +- lib/src/content_blocker.dart | 2 +- lib/src/context_menu.dart | 2 +- lib/src/cookie_manager.dart | 2 +- lib/src/http_auth_credentials_database.dart | 2 +- .../apple/in_app_browser_options.dart | 2 +- lib/src/in_app_browser/in_app_browser.dart | 2 +- .../in_app_browser_settings.dart | 2 +- .../android/in_app_webview_controller.dart | 2 +- .../android/in_app_webview_options.dart | 2 +- .../apple/in_app_webview_controller.dart | 2 +- .../apple/in_app_webview_options.dart | 2 +- .../headless_in_app_webview.dart | 2 +- lib/src/in_app_webview/in_app_webview.dart | 2 +- .../in_app_webview_controller.dart | 2 +- .../in_app_webview_settings.dart | 2 +- lib/src/in_app_webview/webview.dart | 2 +- lib/src/main.dart | 3 +- .../pull_to_refresh_controller.dart | 2 +- .../pull_to_refresh_settings.dart | 2 +- lib/src/types.dart | 10852 ---------------- lib/src/types/action_mode_menu_item.dart | 140 + lib/src/types/ajax_request.dart | 158 + lib/src/types/ajax_request_action.dart | 39 + lib/src/types/ajax_request_event.dart | 56 + lib/src/types/ajax_request_event_type.dart | 64 + lib/src/types/ajax_request_headers.dart | 46 + lib/src/types/ajax_request_ready_state.dart | 70 + lib/src/types/attributed_string.dart | 308 + .../attributed_string_text_effect_style.dart | 81 + lib/src/types/cache_mode.dart | 129 + .../types/call_async_javascript_result.dart | 27 + lib/src/types/client_cert_challenge.dart | 54 + lib/src/types/client_cert_response.dart | 58 + .../types/client_cert_response_action.dart | 25 + lib/src/types/compress_format.dart | 74 + lib/src/types/console_message.dart | 45 + lib/src/types/console_message_level.dart | 68 + .../types/content_blocker_action_type.dart | 52 + .../content_blocker_trigger_load_type.dart | 46 + ...content_blocker_trigger_resource_type.dart | 61 + lib/src/types/content_world.dart | 52 + lib/src/types/cookie.dart | 82 + lib/src/types/create_window_action.dart | 158 + lib/src/types/cross_origin.dart | 47 + .../types/css_link_html_tag_attributes.dart | 72 + lib/src/types/custom_scheme_response.dart | 40 + lib/src/types/custom_tabs_share_state.dart | 56 + lib/src/types/data_detector_types.dart | 165 + lib/src/types/dismiss_button_style.dart | 118 + lib/src/types/download_start_request.dart | 73 + lib/src/types/favicon.dart | 38 + lib/src/types/fetch_request.dart | 126 + lib/src/types/fetch_request_action.dart | 22 + lib/src/types/fetch_request_credential.dart | 34 + .../fetch_request_credential_default.dart | 38 + .../fetch_request_federated_credential.dart | 62 + .../fetch_request_password_credential.dart | 57 + lib/src/types/force_dark.dart | 120 + lib/src/types/form_resubmission_action.dart | 37 + lib/src/types/frame_info.dart | 99 + ...ation_permission_show_prompt_response.dart | 31 + lib/src/types/http_auth_response.dart | 44 + lib/src/types/http_auth_response_action.dart | 26 + .../types/http_authentication_challenge.dart | 99 + .../types/http_cookie_same_site_policy.dart | 56 + .../types/in_app_webview_hit_test_result.dart | 38 + .../in_app_webview_hit_test_result_type.dart | 89 + .../types/in_app_webview_initial_data.dart | 78 + lib/src/types/in_app_webview_rect.dart | 37 + .../types/javascript_handler_callback.dart | 15 + lib/src/types/js_alert_request.dart | 64 + lib/src/types/js_alert_response.dart | 44 + lib/src/types/js_alert_response_action.dart | 19 + lib/src/types/js_before_unload_request.dart | 38 + lib/src/types/js_before_unload_response.dart | 49 + .../js_before_unload_response_action.dart | 22 + lib/src/types/js_confirm_request.dart | 63 + lib/src/types/js_confirm_response.dart | 47 + lib/src/types/js_confirm_response_action.dart | 22 + lib/src/types/js_prompt_request.dart | 69 + lib/src/types/js_prompt_response.dart | 59 + lib/src/types/js_prompt_response_action.dart | 22 + lib/src/types/layout_algorithm.dart | 105 + .../types/layout_in_display_cutout_mode.dart | 149 + lib/src/types/loaded_resource.dart | 51 + lib/src/types/login_request.dart | 43 + lib/src/types/main.dart | 144 + lib/src/types/media_playback_state.dart | 62 + lib/src/types/meta_tag.dart | 31 + lib/src/types/meta_tag_attribute.dart | 30 + lib/src/types/mixed_content_mode.dart | 134 + lib/src/types/modal_presentation_style.dart | 205 + lib/src/types/modal_transition_style.dart | 139 + lib/src/types/navigation_action.dart | 180 + lib/src/types/navigation_action_policy.dart | 35 + lib/src/types/navigation_response.dart | 101 + lib/src/types/navigation_response_action.dart | 64 + lib/src/types/navigation_type.dart | 153 + lib/src/types/on_post_message_callback.dart | 5 + lib/src/types/over_scroll_mode.dart | 121 + lib/src/types/pdf_configuration.dart | 57 + lib/src/types/permission_request.dart | 63 + lib/src/types/permission_resource_type.dart | 129 + lib/src/types/permission_response.dart | 65 + lib/src/types/permission_response_action.dart | 50 + lib/src/types/pull_to_refresh_size.dart | 103 + lib/src/types/referrer_policy.dart | 78 + lib/src/types/render_process_gone_detail.dart | 48 + lib/src/types/renderer_priority.dart | 60 + lib/src/types/renderer_priority_policy.dart | 48 + .../types/request_focus_node_href_result.dart | 30 + lib/src/types/request_image_ref_result.dart | 26 + lib/src/types/safe_browsing_response.dart | 33 + .../types/safe_browsing_response_action.dart | 26 + lib/src/types/safe_browsing_threat.dart | 76 + lib/src/types/sandbox.dart | 102 + lib/src/types/screenshot_configuration.dart | 77 + lib/src/types/script_html_tag_attributes.dart | 109 + lib/src/types/scrollbar_style.dart | 155 + ...iew_content_inset_adjustment_behavior.dart | 138 + .../types/scrollview_deceleration_rate.dart | 88 + lib/src/types/security_origin.dart | 82 + lib/src/types/selection_granularity.dart | 103 + lib/src/types/server_trust_auth_response.dart | 26 + .../server_trust_auth_response_action.dart | 22 + lib/src/types/server_trust_challenge.dart | 21 + .../should_allow_deprecated_tls_action.dart | 59 + lib/src/types/ssl_certificate.dart | 112 + lib/src/types/ssl_certificate_dname.dart | 62 + lib/src/types/ssl_error.dart | 68 + lib/src/types/ssl_error_type.dart | 327 + ...ted_web_activity_default_display_mode.dart | 23 + .../trusted_web_activity_display_mode.dart | 17 + ...d_web_activity_immersive_display_mode.dart | 64 + ...usted_web_activity_screen_orientation.dart | 115 + lib/src/types/underline_style.dart | 187 + .../types/url_authentication_challenge.dart | 40 + lib/src/types/url_credential.dart | 108 + lib/src/types/url_credential_persistence.dart | 127 + lib/src/types/url_protection_space.dart | 219 + ...rotection_space_authentication_method.dart | 128 + ...rotection_space_http_auth_credentials.dart | 65 + .../url_protection_space_proxy_type.dart | 119 + lib/src/types/url_request.dart | 273 + lib/src/types/url_request_cache_policy.dart | 187 + .../url_request_network_service_type.dart | 195 + lib/src/types/url_response.dart | 142 + .../types/user_preferred_content_mode.dart | 56 + lib/src/types/user_script.dart | 67 + lib/src/types/user_script_injection_time.dart | 57 + .../types/vertical_scrollbar_position.dart | 121 + lib/src/types/web_archive_format.dart | 40 + lib/src/types/web_history.dart | 61 + lib/src/types/web_history_item.dart | 46 + lib/src/types/web_message_callback.dart | 5 + lib/src/types/web_resource_request.dart | 80 + lib/src/types/web_resource_response.dart | 62 + lib/src/types/web_storage_origin.dart | 64 + lib/src/types/web_storage_type.dart | 47 + lib/src/types/website_data_record.dart | 72 + lib/src/types/website_data_type.dart | 217 + lib/src/types/webview_implementation.dart | 45 + lib/src/types/webview_package_info.dart | 71 + .../types/webview_render_process_action.dart | 24 + lib/src/types/window_features.dart | 155 + .../web/headless_inappwebview_manager.dart | 2 +- lib/src/web/in_app_web_view_web_element.dart | 2 +- lib/src/web_message/web_message_channel.dart | 2 +- lib/src/web_message/web_message_listener.dart | 2 +- .../android/web_storage_manager.dart | 2 +- .../web_storage/ios/web_storage_manager.dart | 2 +- lib/src/web_storage/web_storage.dart | 2 +- lib/src/web_storage/web_storage_manager.dart | 2 +- 177 files changed, 11654 insertions(+), 10883 deletions(-) delete mode 100755 lib/src/types.dart create mode 100644 lib/src/types/action_mode_menu_item.dart create mode 100644 lib/src/types/ajax_request.dart create mode 100644 lib/src/types/ajax_request_action.dart create mode 100644 lib/src/types/ajax_request_event.dart create mode 100644 lib/src/types/ajax_request_event_type.dart create mode 100644 lib/src/types/ajax_request_headers.dart create mode 100644 lib/src/types/ajax_request_ready_state.dart create mode 100644 lib/src/types/attributed_string.dart create mode 100644 lib/src/types/attributed_string_text_effect_style.dart create mode 100644 lib/src/types/cache_mode.dart create mode 100644 lib/src/types/call_async_javascript_result.dart create mode 100644 lib/src/types/client_cert_challenge.dart create mode 100644 lib/src/types/client_cert_response.dart create mode 100644 lib/src/types/client_cert_response_action.dart create mode 100644 lib/src/types/compress_format.dart create mode 100644 lib/src/types/console_message.dart create mode 100644 lib/src/types/console_message_level.dart create mode 100644 lib/src/types/content_blocker_action_type.dart create mode 100644 lib/src/types/content_blocker_trigger_load_type.dart create mode 100644 lib/src/types/content_blocker_trigger_resource_type.dart create mode 100644 lib/src/types/content_world.dart create mode 100644 lib/src/types/cookie.dart create mode 100644 lib/src/types/create_window_action.dart create mode 100644 lib/src/types/cross_origin.dart create mode 100644 lib/src/types/css_link_html_tag_attributes.dart create mode 100644 lib/src/types/custom_scheme_response.dart create mode 100644 lib/src/types/custom_tabs_share_state.dart create mode 100644 lib/src/types/data_detector_types.dart create mode 100644 lib/src/types/dismiss_button_style.dart create mode 100644 lib/src/types/download_start_request.dart create mode 100644 lib/src/types/favicon.dart create mode 100644 lib/src/types/fetch_request.dart create mode 100644 lib/src/types/fetch_request_action.dart create mode 100644 lib/src/types/fetch_request_credential.dart create mode 100644 lib/src/types/fetch_request_credential_default.dart create mode 100644 lib/src/types/fetch_request_federated_credential.dart create mode 100644 lib/src/types/fetch_request_password_credential.dart create mode 100644 lib/src/types/force_dark.dart create mode 100644 lib/src/types/form_resubmission_action.dart create mode 100644 lib/src/types/frame_info.dart create mode 100644 lib/src/types/geolocation_permission_show_prompt_response.dart create mode 100644 lib/src/types/http_auth_response.dart create mode 100644 lib/src/types/http_auth_response_action.dart create mode 100644 lib/src/types/http_authentication_challenge.dart create mode 100644 lib/src/types/http_cookie_same_site_policy.dart create mode 100644 lib/src/types/in_app_webview_hit_test_result.dart create mode 100644 lib/src/types/in_app_webview_hit_test_result_type.dart create mode 100644 lib/src/types/in_app_webview_initial_data.dart create mode 100644 lib/src/types/in_app_webview_rect.dart create mode 100644 lib/src/types/javascript_handler_callback.dart create mode 100644 lib/src/types/js_alert_request.dart create mode 100644 lib/src/types/js_alert_response.dart create mode 100644 lib/src/types/js_alert_response_action.dart create mode 100644 lib/src/types/js_before_unload_request.dart create mode 100644 lib/src/types/js_before_unload_response.dart create mode 100644 lib/src/types/js_before_unload_response_action.dart create mode 100644 lib/src/types/js_confirm_request.dart create mode 100644 lib/src/types/js_confirm_response.dart create mode 100644 lib/src/types/js_confirm_response_action.dart create mode 100644 lib/src/types/js_prompt_request.dart create mode 100644 lib/src/types/js_prompt_response.dart create mode 100644 lib/src/types/js_prompt_response_action.dart create mode 100644 lib/src/types/layout_algorithm.dart create mode 100644 lib/src/types/layout_in_display_cutout_mode.dart create mode 100644 lib/src/types/loaded_resource.dart create mode 100644 lib/src/types/login_request.dart create mode 100644 lib/src/types/main.dart create mode 100644 lib/src/types/media_playback_state.dart create mode 100644 lib/src/types/meta_tag.dart create mode 100644 lib/src/types/meta_tag_attribute.dart create mode 100644 lib/src/types/mixed_content_mode.dart create mode 100644 lib/src/types/modal_presentation_style.dart create mode 100644 lib/src/types/modal_transition_style.dart create mode 100644 lib/src/types/navigation_action.dart create mode 100644 lib/src/types/navigation_action_policy.dart create mode 100644 lib/src/types/navigation_response.dart create mode 100644 lib/src/types/navigation_response_action.dart create mode 100644 lib/src/types/navigation_type.dart create mode 100644 lib/src/types/on_post_message_callback.dart create mode 100644 lib/src/types/over_scroll_mode.dart create mode 100644 lib/src/types/pdf_configuration.dart create mode 100644 lib/src/types/permission_request.dart create mode 100644 lib/src/types/permission_resource_type.dart create mode 100644 lib/src/types/permission_response.dart create mode 100644 lib/src/types/permission_response_action.dart create mode 100644 lib/src/types/pull_to_refresh_size.dart create mode 100644 lib/src/types/referrer_policy.dart create mode 100644 lib/src/types/render_process_gone_detail.dart create mode 100644 lib/src/types/renderer_priority.dart create mode 100644 lib/src/types/renderer_priority_policy.dart create mode 100644 lib/src/types/request_focus_node_href_result.dart create mode 100644 lib/src/types/request_image_ref_result.dart create mode 100644 lib/src/types/safe_browsing_response.dart create mode 100644 lib/src/types/safe_browsing_response_action.dart create mode 100644 lib/src/types/safe_browsing_threat.dart create mode 100644 lib/src/types/sandbox.dart create mode 100644 lib/src/types/screenshot_configuration.dart create mode 100644 lib/src/types/script_html_tag_attributes.dart create mode 100644 lib/src/types/scrollbar_style.dart create mode 100644 lib/src/types/scrollview_content_inset_adjustment_behavior.dart create mode 100644 lib/src/types/scrollview_deceleration_rate.dart create mode 100644 lib/src/types/security_origin.dart create mode 100644 lib/src/types/selection_granularity.dart create mode 100644 lib/src/types/server_trust_auth_response.dart create mode 100644 lib/src/types/server_trust_auth_response_action.dart create mode 100644 lib/src/types/server_trust_challenge.dart create mode 100644 lib/src/types/should_allow_deprecated_tls_action.dart create mode 100644 lib/src/types/ssl_certificate.dart create mode 100644 lib/src/types/ssl_certificate_dname.dart create mode 100644 lib/src/types/ssl_error.dart create mode 100644 lib/src/types/ssl_error_type.dart create mode 100644 lib/src/types/trusted_web_activity_default_display_mode.dart create mode 100644 lib/src/types/trusted_web_activity_display_mode.dart create mode 100644 lib/src/types/trusted_web_activity_immersive_display_mode.dart create mode 100644 lib/src/types/trusted_web_activity_screen_orientation.dart create mode 100644 lib/src/types/underline_style.dart create mode 100644 lib/src/types/url_authentication_challenge.dart create mode 100644 lib/src/types/url_credential.dart create mode 100644 lib/src/types/url_credential_persistence.dart create mode 100644 lib/src/types/url_protection_space.dart create mode 100644 lib/src/types/url_protection_space_authentication_method.dart create mode 100644 lib/src/types/url_protection_space_http_auth_credentials.dart create mode 100644 lib/src/types/url_protection_space_proxy_type.dart create mode 100644 lib/src/types/url_request.dart create mode 100644 lib/src/types/url_request_cache_policy.dart create mode 100644 lib/src/types/url_request_network_service_type.dart create mode 100644 lib/src/types/url_response.dart create mode 100644 lib/src/types/user_preferred_content_mode.dart create mode 100644 lib/src/types/user_script.dart create mode 100644 lib/src/types/user_script_injection_time.dart create mode 100644 lib/src/types/vertical_scrollbar_position.dart create mode 100644 lib/src/types/web_archive_format.dart create mode 100644 lib/src/types/web_history.dart create mode 100644 lib/src/types/web_history_item.dart create mode 100644 lib/src/types/web_message_callback.dart create mode 100644 lib/src/types/web_resource_request.dart create mode 100644 lib/src/types/web_resource_response.dart create mode 100644 lib/src/types/web_storage_origin.dart create mode 100644 lib/src/types/web_storage_type.dart create mode 100644 lib/src/types/website_data_record.dart create mode 100644 lib/src/types/website_data_type.dart create mode 100644 lib/src/types/webview_implementation.dart create mode 100644 lib/src/types/webview_package_info.dart create mode 100644 lib/src/types/webview_render_process_action.dart create mode 100644 lib/src/types/window_features.dart diff --git a/lib/src/android/service_worker_controller.dart b/lib/src/android/service_worker_controller.dart index 4b7c56cf..cb58e9ea 100644 --- a/lib/src/android/service_worker_controller.dart +++ b/lib/src/android/service_worker_controller.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'package:flutter/services.dart'; import 'webview_feature.dart'; -import '../types.dart'; +import '../types/main.dart'; ///Class that manages Service Workers used by [WebView]. /// diff --git a/lib/src/chrome_safari_browser/android/chrome_custom_tabs_options.dart b/lib/src/chrome_safari_browser/android/chrome_custom_tabs_options.dart index b338dcfb..bea02314 100755 --- a/lib/src/chrome_safari_browser/android/chrome_custom_tabs_options.dart +++ b/lib/src/chrome_safari_browser/android/chrome_custom_tabs_options.dart @@ -1,7 +1,7 @@ import 'dart:ui'; import '../../util.dart'; -import '../../types.dart'; +import '../../types/main.dart'; import '../chrome_safari_browser_settings.dart'; import '../chrome_safari_browser.dart'; diff --git a/lib/src/chrome_safari_browser/apple/safari_options.dart b/lib/src/chrome_safari_browser/apple/safari_options.dart index 717984cc..01b8a785 100755 --- a/lib/src/chrome_safari_browser/apple/safari_options.dart +++ b/lib/src/chrome_safari_browser/apple/safari_options.dart @@ -1,7 +1,7 @@ import 'dart:ui'; import '../../util.dart'; -import '../../types.dart'; +import '../../types/main.dart'; import '../chrome_safari_browser_settings.dart'; import '../chrome_safari_browser.dart'; diff --git a/lib/src/chrome_safari_browser/chrome_safari_browser_settings.dart b/lib/src/chrome_safari_browser/chrome_safari_browser_settings.dart index 8e9ea0f7..be31ed39 100755 --- a/lib/src/chrome_safari_browser/chrome_safari_browser_settings.dart +++ b/lib/src/chrome_safari_browser/chrome_safari_browser_settings.dart @@ -5,7 +5,7 @@ import 'package:flutter/foundation.dart'; import '../util.dart'; import 'android/chrome_custom_tabs_options.dart'; import 'apple/safari_options.dart'; -import '../types.dart'; +import '../types/main.dart'; class ChromeSafariBrowserOptions { Map toMap() { diff --git a/lib/src/content_blocker.dart b/lib/src/content_blocker.dart index 24c79eb1..4f18e5f6 100755 --- a/lib/src/content_blocker.dart +++ b/lib/src/content_blocker.dart @@ -1,4 +1,4 @@ -import 'types.dart'; +import 'types/main.dart'; ///Class that represents a set of rules to use block content in the browser window. /// diff --git a/lib/src/context_menu.dart b/lib/src/context_menu.dart index f4f56361..4d1f6286 100644 --- a/lib/src/context_menu.dart +++ b/lib/src/context_menu.dart @@ -1,7 +1,7 @@ import 'package:flutter/foundation.dart'; import 'in_app_webview/webview.dart'; -import 'types.dart'; +import 'types/main.dart'; ///Class that represents the WebView context menu. It used by [WebView.contextMenu]. /// diff --git a/lib/src/cookie_manager.dart b/lib/src/cookie_manager.dart index b615613a..a5cd20c3 100755 --- a/lib/src/cookie_manager.dart +++ b/lib/src/cookie_manager.dart @@ -8,7 +8,7 @@ import 'in_app_webview/in_app_webview_settings.dart'; import 'in_app_webview/headless_in_app_webview.dart'; import 'platform_util.dart'; -import 'types.dart'; +import 'types/main.dart'; ///Class that implements a singleton object (shared instance) which manages the cookies used by WebView instances. ///On Android, it is implemented using [CookieManager](https://developer.android.com/reference/android/webkit/CookieManager). diff --git a/lib/src/http_auth_credentials_database.dart b/lib/src/http_auth_credentials_database.dart index 7d4d8d5a..366b46ac 100755 --- a/lib/src/http_auth_credentials_database.dart +++ b/lib/src/http_auth_credentials_database.dart @@ -1,6 +1,6 @@ import 'dart:async'; -import 'types.dart'; +import 'types/main.dart'; import 'package:flutter/services.dart'; ///Class that implements a singleton object (shared instance) which manages the shared HTTP auth credentials cache. diff --git a/lib/src/in_app_browser/apple/in_app_browser_options.dart b/lib/src/in_app_browser/apple/in_app_browser_options.dart index bb97f346..87f5a9d7 100755 --- a/lib/src/in_app_browser/apple/in_app_browser_options.dart +++ b/lib/src/in_app_browser/apple/in_app_browser_options.dart @@ -5,7 +5,7 @@ import '../../in_app_webview/apple/in_app_webview_options.dart'; import '../in_app_browser_settings.dart'; import '../in_app_browser.dart'; -import '../../types.dart'; +import '../../types/main.dart'; import '../../util.dart'; ///This class represents all the iOS-only [InAppBrowser] options available. diff --git a/lib/src/in_app_browser/in_app_browser.dart b/lib/src/in_app_browser/in_app_browser.dart index b72c02a7..01d2d052 100755 --- a/lib/src/in_app_browser/in_app_browser.dart +++ b/lib/src/in_app_browser/in_app_browser.dart @@ -6,7 +6,7 @@ import 'package:flutter/services.dart'; import '../context_menu.dart'; import '../pull_to_refresh/main.dart'; -import '../types.dart'; +import '../types/main.dart'; import '../in_app_webview/in_app_webview_controller.dart'; import '../in_app_webview/in_app_webview_settings.dart'; diff --git a/lib/src/in_app_browser/in_app_browser_settings.dart b/lib/src/in_app_browser/in_app_browser_settings.dart index dad89bee..b3c7b408 100755 --- a/lib/src/in_app_browser/in_app_browser_settings.dart +++ b/lib/src/in_app_browser/in_app_browser_settings.dart @@ -1,7 +1,7 @@ import 'dart:ui'; import 'package:flutter/foundation.dart'; -import 'package:flutter_inappwebview/src/types.dart'; +import 'package:flutter_inappwebview/src/types/main.dart'; import '../util.dart'; diff --git a/lib/src/in_app_webview/android/in_app_webview_controller.dart b/lib/src/in_app_webview/android/in_app_webview_controller.dart index f75f2d63..227d6880 100644 --- a/lib/src/in_app_webview/android/in_app_webview_controller.dart +++ b/lib/src/in_app_webview/android/in_app_webview_controller.dart @@ -2,7 +2,7 @@ import 'dart:core'; import 'package:flutter/services.dart'; -import '../../types.dart'; +import '../../types/main.dart'; import '../../android/webview_feature.dart'; import '../in_app_webview_controller.dart'; diff --git a/lib/src/in_app_webview/android/in_app_webview_options.dart b/lib/src/in_app_webview/android/in_app_webview_options.dart index 41c4cbd8..5a7c7b40 100755 --- a/lib/src/in_app_webview/android/in_app_webview_options.dart +++ b/lib/src/in_app_webview/android/in_app_webview_options.dart @@ -1,7 +1,7 @@ import 'dart:ui'; import '../../util.dart'; -import '../../types.dart'; +import '../../types/main.dart'; import '../../in_app_browser/in_app_browser_settings.dart'; import '../in_app_webview_settings.dart'; import '../webview.dart'; diff --git a/lib/src/in_app_webview/apple/in_app_webview_controller.dart b/lib/src/in_app_webview/apple/in_app_webview_controller.dart index 9c3de23d..233250fe 100644 --- a/lib/src/in_app_webview/apple/in_app_webview_controller.dart +++ b/lib/src/in_app_webview/apple/in_app_webview_controller.dart @@ -3,7 +3,7 @@ import 'dart:typed_data'; import 'package:flutter/services.dart'; -import '../../types.dart'; +import '../../types/main.dart'; import '../in_app_webview_controller.dart'; ///Class mixin that contains only iOS-specific methods for the WebView. diff --git a/lib/src/in_app_webview/apple/in_app_webview_options.dart b/lib/src/in_app_webview/apple/in_app_webview_options.dart index f6788dcc..4cc00046 100755 --- a/lib/src/in_app_webview/apple/in_app_webview_options.dart +++ b/lib/src/in_app_webview/apple/in_app_webview_options.dart @@ -1,4 +1,4 @@ -import '../../types.dart'; +import '../../types/main.dart'; import '../../in_app_browser/in_app_browser_settings.dart'; 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 b2f6d395..8cdaef19 100644 --- a/lib/src/in_app_webview/headless_in_app_webview.dart +++ b/lib/src/in_app_webview/headless_in_app_webview.dart @@ -6,7 +6,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_inappwebview/src/util.dart'; import '../context_menu.dart'; -import '../types.dart'; +import '../types/main.dart'; import 'webview.dart'; import 'in_app_webview_controller.dart'; import 'in_app_webview_settings.dart'; diff --git a/lib/src/in_app_webview/in_app_webview.dart b/lib/src/in_app_webview/in_app_webview.dart index 8e1a83af..85953a2b 100755 --- a/lib/src/in_app_webview/in_app_webview.dart +++ b/lib/src/in_app_webview/in_app_webview.dart @@ -12,7 +12,7 @@ import 'package:flutter/gestures.dart'; import '../web/web_platform_manager.dart'; import '../context_menu.dart'; -import '../types.dart'; +import '../types/main.dart'; import 'webview.dart'; import 'in_app_webview_controller.dart'; diff --git a/lib/src/in_app_webview/in_app_webview_controller.dart b/lib/src/in_app_webview/in_app_webview_controller.dart index 92e294a7..ff7983ac 100644 --- a/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/lib/src/in_app_webview/in_app_webview_controller.dart @@ -14,7 +14,7 @@ import 'android/in_app_webview_controller.dart'; import 'apple/in_app_webview_controller.dart'; import '../context_menu.dart'; -import '../types.dart'; +import '../types/main.dart'; import '../in_app_browser/in_app_browser.dart'; import '../web_storage/web_storage.dart'; import '../util.dart'; diff --git a/lib/src/in_app_webview/in_app_webview_settings.dart b/lib/src/in_app_webview/in_app_webview_settings.dart index 9731ef67..bcddcd7f 100755 --- a/lib/src/in_app_webview/in_app_webview_settings.dart +++ b/lib/src/in_app_webview/in_app_webview_settings.dart @@ -5,7 +5,7 @@ import 'package:flutter/foundation.dart'; import 'android/in_app_webview_options.dart'; import 'apple/in_app_webview_options.dart'; import '../content_blocker.dart'; -import '../types.dart'; +import '../types/main.dart'; import '../util.dart'; import '../in_app_browser/in_app_browser_settings.dart'; import 'webview.dart'; diff --git a/lib/src/in_app_webview/webview.dart b/lib/src/in_app_webview/webview.dart index d8a50db2..d64725c0 100644 --- a/lib/src/in_app_webview/webview.dart +++ b/lib/src/in_app_webview/webview.dart @@ -7,7 +7,7 @@ import 'package:flutter_inappwebview/flutter_inappwebview_web.dart'; import '../pull_to_refresh/pull_to_refresh_controller.dart'; import '../context_menu.dart'; -import '../types.dart'; +import '../types/main.dart'; import 'in_app_webview_controller.dart'; import 'in_app_webview_settings.dart'; diff --git a/lib/src/main.dart b/lib/src/main.dart index 69027c99..41630bbc 100644 --- a/lib/src/main.dart +++ b/lib/src/main.dart @@ -1,3 +1,4 @@ +export 'types/main.dart'; export 'in_app_webview/main.dart'; export 'in_app_browser/main.dart'; export 'chrome_safari_browser/main.dart'; @@ -5,7 +6,7 @@ export 'android/main.dart'; export 'apple/main.dart'; export 'x509_certificate/main.dart'; export 'web_storage/main.dart'; -export 'types.dart'; +export 'types/main.dart'; export 'cookie_manager.dart'; export 'in_app_localhost_server.dart'; export 'content_blocker.dart'; diff --git a/lib/src/pull_to_refresh/pull_to_refresh_controller.dart b/lib/src/pull_to_refresh/pull_to_refresh_controller.dart index 927fffe0..12e37900 100644 --- a/lib/src/pull_to_refresh/pull_to_refresh_controller.dart +++ b/lib/src/pull_to_refresh/pull_to_refresh_controller.dart @@ -4,7 +4,7 @@ import 'package:flutter/services.dart'; import '../in_app_webview/webview.dart'; import '../in_app_browser/in_app_browser.dart'; import '../util.dart'; -import '../types.dart'; +import '../types/main.dart'; import '../in_app_webview/in_app_webview_settings.dart'; import 'pull_to_refresh_settings.dart'; diff --git a/lib/src/pull_to_refresh/pull_to_refresh_settings.dart b/lib/src/pull_to_refresh/pull_to_refresh_settings.dart index 6441be23..03da4ffe 100644 --- a/lib/src/pull_to_refresh/pull_to_refresh_settings.dart +++ b/lib/src/pull_to_refresh/pull_to_refresh_settings.dart @@ -1,6 +1,6 @@ import 'dart:ui'; import '../util.dart'; -import '../types.dart'; +import '../types/main.dart'; ///Pull-To-Refresh Settings class PullToRefreshSettings { diff --git a/lib/src/types.dart b/lib/src/types.dart deleted file mode 100755 index 25a0e4e9..00000000 --- a/lib/src/types.dart +++ /dev/null @@ -1,10852 +0,0 @@ -import 'dart:collection'; -import 'dart:typed_data'; -import 'dart:convert'; -import 'dart:ui'; - -import 'package:flutter/foundation.dart'; - -import 'x509_certificate/x509_certificate.dart'; -import 'x509_certificate/asn1_distinguished_names.dart'; - -import 'in_app_webview/webview.dart'; -import 'in_app_webview/in_app_webview_controller.dart'; -import 'http_auth_credentials_database.dart'; -import 'cookie_manager.dart'; -import 'web_storage/web_storage.dart'; -import 'pull_to_refresh/pull_to_refresh_controller.dart'; -import 'pull_to_refresh/pull_to_refresh_settings.dart'; -import 'util.dart'; -import 'web_message/web_message_listener.dart'; -import 'web_message/web_message_channel.dart'; -import 'web_storage/android/web_storage_manager.dart'; - -///This type represents a callback, added with [InAppWebViewController.addJavaScriptHandler], that listens to post messages sent from JavaScript. -/// -///The Android implementation uses [addJavascriptInterface](https://developer.android.com/reference/android/webkit/WebView#addJavascriptInterface(java.lang.Object,%20java.lang.String)). -///The iOS implementation uses [addScriptMessageHandler](https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1537172-addscriptmessagehandler?language=objc) -/// -///The JavaScript function that can be used to call the handler is `window.flutter_inappwebview.callHandler(handlerName , ...args);`, where `args` are [rest parameters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters). -///The `args` will be stringified automatically using `JSON.stringify(args)` method and then they will be decoded on the Dart side. -/// -///Also, a [JavaScriptHandlerCallback] can return json data to the JavaScript side. -///In this case, simply return data that you want to send and it will be automatically json encoded using [jsonEncode] from the `dart:convert` library. -typedef dynamic JavaScriptHandlerCallback(List arguments); - -///The listener for handling [WebMessageListener] events sent by a `postMessage()` on the injected JavaScript object. -typedef void OnPostMessageCallback(String? message, Uri? sourceOrigin, - bool isMainFrame, JavaScriptReplyProxy replyProxy); - -///The listener for handling [WebMessagePort] events. -///The message callback methods are called on the main thread. -typedef void WebMessageCallback(String? message); - -///Class representing the level of a console message. -class ConsoleMessageLevel { - final int _value; - - const ConsoleMessageLevel._internal(this._value); - - static final Set values = [ - ConsoleMessageLevel.TIP, - ConsoleMessageLevel.LOG, - ConsoleMessageLevel.WARNING, - ConsoleMessageLevel.ERROR, - ConsoleMessageLevel.DEBUG, - ].toSet(); - - static ConsoleMessageLevel? fromValue(int? value) { - if (value != null) { - try { - return ConsoleMessageLevel.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 0: - return "TIP"; - case 2: - return "WARNING"; - case 3: - return "ERROR"; - case 4: - return "DEBUG"; - case 1: - default: - return "LOG"; - } - } - - static const TIP = const ConsoleMessageLevel._internal(0); - static const LOG = const ConsoleMessageLevel._internal(1); - static const WARNING = const ConsoleMessageLevel._internal(2); - static const ERROR = const ConsoleMessageLevel._internal(3); - static const DEBUG = const ConsoleMessageLevel._internal(4); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class representing a resource response of the [WebView]. -///It is used by the method [WebView.onLoadResource]. -class LoadedResource { - ///A string representing the type of resource. - String? initiatorType; - - ///Resource URL. - Uri? url; - - ///Returns the [DOMHighResTimeStamp](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp) for the time a resource fetch started. - double? startTime; - - ///Returns the [DOMHighResTimeStamp](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp) duration to fetch a resource. - double? duration; - - LoadedResource({this.initiatorType, this.url, this.startTime, this.duration}); - - static LoadedResource? fromMap(Map? map) { - if (map == null) { - return null; - } - return LoadedResource( - initiatorType: map["initiatorType"], - url: map["url"] != null ? Uri.parse(map["url"]) : null, - startTime: map["startTime"], - duration: map["duration"]); - } - - Map toMap() { - return { - "initiatorType": initiatorType, - "url": url?.toString(), - "startTime": startTime, - "duration": duration - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Initial [data] as a content for an [WebView] instance, using [baseUrl] as the base URL for it. -class InAppWebViewInitialData { - ///A String of data in the given encoding. - String data; - - ///The MIME type of the data, e.g. "text/html". The default value is `"text/html"`. - String mimeType; - - ///The encoding of the data. The default value is `"utf8"`. - String encoding; - - ///The URL to use as the page's base URL. The default value is `about:blank`. - late Uri baseUrl; - - ///Use [historyUrl] instead. - @Deprecated('Use historyUrl instead') - late Uri androidHistoryUrl; - - ///The URL to use as the history entry. The default value is `about:blank`. If non-null, this must be a valid URL. - /// - ///This parameter is used only on Android. - late Uri historyUrl; - - InAppWebViewInitialData( - {required this.data, - this.mimeType = "text/html", - this.encoding = "utf8", - Uri? baseUrl, - @Deprecated('Use historyUrl instead') Uri? androidHistoryUrl, - Uri? historyUrl}) { - this.baseUrl = baseUrl == null ? Uri.parse("about:blank") : baseUrl; - this.historyUrl = historyUrl == null - ? (androidHistoryUrl == null - ? Uri.parse("about:blank") - : androidHistoryUrl) - : historyUrl; - // ignore: deprecated_member_use_from_same_package - this.androidHistoryUrl = this.historyUrl; - } - - static InAppWebViewInitialData? fromMap(Map? map) { - if (map == null) { - return null; - } - return InAppWebViewInitialData( - data: map["data"], - mimeType: map["mimeType"], - encoding: map["encoding"], - baseUrl: map["baseUrl"], - // ignore: deprecated_member_use_from_same_package - androidHistoryUrl: map["androidHistoryUrl"], - historyUrl: map["historyUrl"]); - } - - Map toMap() { - return { - "data": data, - "mimeType": mimeType, - "encoding": encoding, - "baseUrl": baseUrl.toString(), - "historyUrl": historyUrl.toString() - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class representing a resource request of the WebView used by the event [WebView.shouldInterceptRequest]. -///**NOTE**: available only on Android. -/// -///**Official Android API**: https://developer.android.com/reference/android/webkit/WebResourceRequest -class WebResourceRequest { - ///The URL for which the resource request was made. - Uri url; - - ///The headers associated with the request. - /// - ///**NOTE**: available on Android 21+. For Android < 21 it will be always `null`. - Map? headers; - - ///The method associated with the request, for example `GET`. - /// - ///**NOTE**: available on Android 21+. For Android < 21 it will be always "GET". - String? method; - - ///Gets whether a gesture (such as a click) was associated with the request. - ///For security reasons in certain situations this method may return `false` even though - ///the sequence of events which caused the request to be created was initiated by a user - ///gesture. - /// - ///**NOTE**: available on Android 21+. For Android < 21 it will be always `false`. - bool? hasGesture; - - ///Whether the request was made in order to fetch the main frame's document. - /// - ///**NOTE**: available on Android 21+. For Android < 21 it will be always `true`. - bool? isForMainFrame; - - ///Whether the request was a result of a server-side redirect. - /// - ///**NOTE**: available on Android 21+. For Android < 21 it will be always `false`. - bool? isRedirect; - - WebResourceRequest( - {required this.url, - this.headers, - required this.method, - required this.hasGesture, - required this.isForMainFrame, - required this.isRedirect}); - - static WebResourceRequest? fromMap(Map? map) { - if (map == null) { - return null; - } - - return WebResourceRequest( - url: Uri.parse(map["url"]), - headers: map["headers"]?.cast(), - method: map["method"], - hasGesture: map["hasGesture"], - isForMainFrame: map["isForMainFrame"], - isRedirect: map["isRedirect"]); - } - - Map toMap() { - return { - "url": url.toString(), - "headers": headers, - "method": method, - "hasGesture": hasGesture, - "isForMainFrame": isForMainFrame, - "isRedirect": isRedirect - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class representing a resource response of the WebView used by the event [WebView.shouldInterceptRequest]. -///**NOTE**: available only on Android. -/// -///**Official Android API**: https://developer.android.com/reference/android/webkit/WebResourceResponse -class WebResourceResponse { - ///The resource response's MIME type, for example `text/html`. - String contentType; - - ///The resource response's encoding. The default value is `utf-8`. - String contentEncoding; - - ///The data provided by the resource response. - Uint8List? data; - - ///The headers for the resource response. If [headers] isn't `null`, then you need to set also [statusCode] and [reasonPhrase]. - /// - ///**NOTE**: available on Android 21+. For Android < 21 it won't be used. - Map? headers; - - ///The status code needs to be in the ranges [100, 299], [400, 599]. Causing a redirect by specifying a 3xx code is not supported. - ///If statusCode is set, then you need to set also [headers] and [reasonPhrase]. This value cannot be `null`. - /// - ///**NOTE**: available on Android 21+. For Android < 21 it won't be used. - int? statusCode; - - ///The phrase describing the status code, for example `"OK"`. Must be non-empty. - ///If reasonPhrase is set, then you need to set also [headers] and [reasonPhrase]. This value cannot be `null`. - /// - ///**NOTE**: available on Android 21+. For Android < 21 it won't be used. - String? reasonPhrase; - - WebResourceResponse( - {this.contentType = "", - this.contentEncoding = "utf-8", - this.data, - this.headers, - this.statusCode, - this.reasonPhrase}); - - Map toMap() { - return { - "contentType": contentType, - "contentEncoding": contentEncoding, - "data": data, - "headers": headers, - "statusCode": statusCode, - "reasonPhrase": reasonPhrase - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class representing the response returned by the [WebView.onLoadResourceCustomScheme] event. -///It allows to load a specific resource. The resource data must be encoded to `base64`. -class CustomSchemeResponse { - ///Data enconded to 'base64'. - Uint8List data; - - ///Content-Type of the data, such as `image/png`. - String contentType; - - ///Content-Encoding of the data, such as `utf-8`. - String contentEncoding; - - CustomSchemeResponse( - {required this.data, - required this.contentType, - this.contentEncoding = 'utf-8'}); - - Map toMap() { - return { - 'contentType': contentType, - 'contentEncoding': contentEncoding, - 'data': data - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class representing a JavaScript console message from WebCore. -///This could be a issued by a call to one of the console logging functions (e.g. console.log('...')) or a JavaScript error on the page. -/// -///To receive notifications of these messages, use the [WebView.onConsoleMessage] event. -class ConsoleMessage { - String message; - ConsoleMessageLevel messageLevel; - - ConsoleMessage( - {this.message = "", this.messageLevel = ConsoleMessageLevel.LOG}); - - static ConsoleMessage? fromMap(Map? map) { - if (map == null) { - return null; - } - return ConsoleMessage( - message: map["message"], - messageLevel: ConsoleMessageLevel.fromValue(map["messageLevel"]) ?? - ConsoleMessageLevel.LOG, - ); - } - - Map toMap() { - return {"message": message, "messageLevel": messageLevel.toValue()}; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///This class contains a snapshot of the current back/forward list for a [WebView]. -class WebHistory { - ///List of all [WebHistoryItem]s. - List? list; - - ///Index of the current [WebHistoryItem]. - int? currentIndex; - - WebHistory({this.list, this.currentIndex}); - - static WebHistory? fromMap(Map? map) { - if (map == null) { - return null; - } - - List>? historyListMap = - map["history"]?.cast>(); - int currentIndex = map["currentIndex"]; - - List historyList = []; - if (historyListMap != null) { - for (var i = 0; i < historyListMap.length; i++) { - var historyItem = historyListMap[i]; - historyList.add(WebHistoryItem( - originalUrl: historyItem["originalUrl"] != null - ? Uri.parse(historyItem["originalUrl"]) - : null, - title: historyItem["title"], - url: historyItem["url"] != null - ? Uri.parse(historyItem["url"]) - : null, - index: i, - offset: i - currentIndex)); - } - } - - return WebHistory(list: historyList, currentIndex: currentIndex); - } - - Map toMap() { - return {"list": list, "currentIndex": currentIndex}; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///A convenience class for accessing fields in an entry in the back/forward list of a WebView. Each [WebHistoryItem] is a snapshot of the requested history item. -class WebHistoryItem { - ///Original url of this history item. - Uri? originalUrl; - - ///Document title of this history item. - String? title; - - ///Url of this history item. - Uri? url; - - ///0-based position index in the back-forward [WebHistory.list]. - int? index; - - ///Position offset respect to the currentIndex of the back-forward [WebHistory.list]. - int? offset; - - WebHistoryItem( - {this.originalUrl, this.title, this.url, this.index, this.offset}); - - Map toMap() { - return { - "originalUrl": originalUrl?.toString(), - "title": title, - "url": url?.toString(), - "index": index, - "offset": offset - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class used by the host application to set the Geolocation permission state for an origin during the [WebView.onGeolocationPermissionsShowPrompt] event. -class GeolocationPermissionShowPromptResponse { - ///The origin for which permissions are set. - String? origin; - - ///Whether or not the origin should be allowed to use the Geolocation API. - bool? allow; - - ///Whether the permission should be retained beyond the lifetime of a page currently being displayed by a WebView - bool? retain; - - GeolocationPermissionShowPromptResponse( - {this.origin, this.allow, this.retain}); - - Map toMap() { - return {"origin": origin, "allow": allow, "retain": retain}; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents the request of the [WebView.onJsAlert] event. -class JsAlertRequest { - ///The url of the page requesting the dialog. - Uri? url; - - ///Message to be displayed in the window. - String? message; - - ///Use [isMainFrame] instead. - @Deprecated("Use isMainFrame instead") - bool? iosIsMainFrame; - - ///Indicates whether the request was made for the main frame. - /// - ///**NOTE**: available only on iOS. - bool? isMainFrame; - - JsAlertRequest( - {this.url, - this.message, - @Deprecated("Use isMainFrame instead") this.iosIsMainFrame, - this.isMainFrame}) { - // ignore: deprecated_member_use_from_same_package - this.isMainFrame = this.isMainFrame ?? this.iosIsMainFrame; - } - - Map toMap() { - return { - "url": url?.toString(), - "message": message, - // ignore: deprecated_member_use_from_same_package - "iosIsMainFrame": isMainFrame ?? iosIsMainFrame, - // ignore: deprecated_member_use_from_same_package - "isMainFrame": isMainFrame ?? iosIsMainFrame - }; - } - - static JsAlertRequest? fromMap(Map? map) { - if (map == null) { - return null; - } - return JsAlertRequest( - url: map["url"] != null ? Uri.parse(map["url"]) : null, - message: map["message"], - // ignore: deprecated_member_use_from_same_package - iosIsMainFrame: map["isMainFrame"], - isMainFrame: map["isMainFrame"], - ); - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class used by [JsAlertResponse] class. -class JsAlertResponseAction { - final int _value; - - const JsAlertResponseAction._internal(this._value); - - int toValue() => _value; - - static const CONFIRM = const JsAlertResponseAction._internal(0); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents the response used by the [WebView.onJsAlert] event to control a JavaScript alert dialog. -class JsAlertResponse { - ///Message to be displayed in the window. - String message; - - ///Title of the confirm button. - String confirmButtonTitle; - - ///Whether the client will handle the alert dialog. - bool handledByClient; - - ///Action used to confirm that the user hit confirm button. - JsAlertResponseAction? action; - - JsAlertResponse( - {this.message = "", - this.handledByClient = false, - this.confirmButtonTitle = "", - this.action = JsAlertResponseAction.CONFIRM}); - - Map toMap() { - return { - "message": message, - "confirmButtonTitle": confirmButtonTitle, - "handledByClient": handledByClient, - "action": action?.toValue() - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents the request of the [WebView.onJsConfirm] event. -class JsConfirmRequest { - ///The url of the page requesting the dialog. - Uri? url; - - ///Message to be displayed in the window. - String? message; - - ///Use [isMainFrame] instead. - @Deprecated("Use isMainFrame instead") - bool? iosIsMainFrame; - - ///Indicates whether the request was made for the main frame. - /// - ///**NOTE**: available only on iOS. - bool? isMainFrame; - - JsConfirmRequest( - {this.url, - this.message, - @Deprecated("Use isMainFrame instead") this.iosIsMainFrame, - this.isMainFrame}) { - // ignore: deprecated_member_use_from_same_package - this.isMainFrame = this.isMainFrame ?? this.iosIsMainFrame; - } - - Map toMap() { - return { - "url": url?.toString(), - "message": message, - // ignore: deprecated_member_use_from_same_package - "iosIsMainFrame": isMainFrame ?? iosIsMainFrame, - // ignore: deprecated_member_use_from_same_package - "isMainFrame": isMainFrame ?? iosIsMainFrame - }; - } - - static JsConfirmRequest? fromMap(Map? map) { - if (map == null) { - return null; - } - return JsConfirmRequest( - url: map["url"] != null ? Uri.parse(map["url"]) : null, - message: map["message"], - // ignore: deprecated_member_use_from_same_package - iosIsMainFrame: map["isMainFrame"], - isMainFrame: map["isMainFrame"]); - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class used by [JsConfirmResponse] class. -class JsConfirmResponseAction { - final int _value; - - const JsConfirmResponseAction._internal(this._value); - - int toValue() => _value; - - static const CONFIRM = const JsConfirmResponseAction._internal(0); - static const CANCEL = const JsConfirmResponseAction._internal(1); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents the response used by the [WebView.onJsConfirm] event to control a JavaScript confirm dialog. -class JsConfirmResponse { - ///Message to be displayed in the window. - String message; - - ///Title of the confirm button. - String confirmButtonTitle; - - ///Title of the cancel button. - String cancelButtonTitle; - - ///Whether the client will handle the confirm dialog. - bool handledByClient; - - ///Action used to confirm that the user hit confirm or cancel button. - JsConfirmResponseAction? action; - - JsConfirmResponse( - {this.message = "", - this.handledByClient = false, - this.confirmButtonTitle = "", - this.cancelButtonTitle = "", - this.action = JsConfirmResponseAction.CANCEL}); - - Map toMap() { - return { - "message": message, - "confirmButtonTitle": confirmButtonTitle, - "cancelButtonTitle": cancelButtonTitle, - "handledByClient": handledByClient, - "action": action?.toValue() - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents the request of the [WebView.onJsPrompt] event. -class JsPromptRequest { - ///The url of the page requesting the dialog. - Uri? url; - - ///Message to be displayed in the window. - String? message; - - ///The default value displayed in the prompt dialog. - String? defaultValue; - - ///Use [isMainFrame] instead. - @Deprecated("Use isMainFrame instead") - bool? iosIsMainFrame; - - ///Indicates whether the request was made for the main frame. - /// - ///**NOTE**: available only on iOS. - bool? isMainFrame; - - JsPromptRequest( - {this.url, - this.message, - this.defaultValue, - @Deprecated("Use isMainFrame instead") this.iosIsMainFrame, - this.isMainFrame}) { - // ignore: deprecated_member_use_from_same_package - this.isMainFrame = this.isMainFrame ?? this.iosIsMainFrame; - } - - Map toMap() { - return { - "url": url?.toString(), - "message": message, - "defaultValue": defaultValue, - // ignore: deprecated_member_use_from_same_package - "iosIsMainFrame": isMainFrame ?? iosIsMainFrame, - // ignore: deprecated_member_use_from_same_package - "isMainFrame": isMainFrame ?? iosIsMainFrame - }; - } - - static JsPromptRequest? fromMap(Map? map) { - if (map == null) { - return null; - } - return JsPromptRequest( - url: map["url"] != null ? Uri.parse(map["url"]) : null, - message: map["message"], - defaultValue: map["defaultValue"], - // ignore: deprecated_member_use_from_same_package - iosIsMainFrame: map["isMainFrame"], - isMainFrame: map["isMainFrame"]); - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class used by [JsPromptResponse] class. -class JsPromptResponseAction { - final int _value; - - const JsPromptResponseAction._internal(this._value); - - int toValue() => _value; - - static const CONFIRM = const JsPromptResponseAction._internal(0); - static const CANCEL = const JsPromptResponseAction._internal(1); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents the response used by the [WebView.onJsPrompt] event to control a JavaScript prompt dialog. -class JsPromptResponse { - ///Message to be displayed in the window. - String message; - - ///The default value displayed in the prompt dialog. - String defaultValue; - - ///Title of the confirm button. - String confirmButtonTitle; - - ///Title of the cancel button. - String cancelButtonTitle; - - ///Whether the client will handle the prompt dialog. - bool handledByClient; - - ///Value of the prompt dialog. - String? value; - - ///Action used to confirm that the user hit confirm or cancel button. - JsPromptResponseAction? action; - - JsPromptResponse( - {this.message = "", - this.defaultValue = "", - this.handledByClient = false, - this.confirmButtonTitle = "", - this.cancelButtonTitle = "", - this.value, - this.action = JsPromptResponseAction.CANCEL}); - - Map toMap() { - return { - "message": message, - "defaultValue": defaultValue, - "confirmButtonTitle": confirmButtonTitle, - "cancelButtonTitle": cancelButtonTitle, - "handledByClient": handledByClient, - "value": value, - "action": action?.toValue() - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents the request of the [WebView.onJsBeforeUnload] event. -class JsBeforeUnloadRequest { - ///The url of the page requesting the dialog. - Uri? url; - - ///Message to be displayed in the window. - String? message; - - JsBeforeUnloadRequest({this.url, this.message}); - - static JsBeforeUnloadRequest? fromMap(Map? map) { - if (map == null) { - return null; - } - return JsBeforeUnloadRequest( - url: map["url"] != null ? Uri.parse(map["url"]) : null, - message: map["message"], - ); - } - - Map toMap() { - return {"url": url?.toString(), "message": message}; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class used by [JsBeforeUnloadResponse] class. -class JsBeforeUnloadResponseAction { - final int _value; - - const JsBeforeUnloadResponseAction._internal(this._value); - - int toValue() => _value; - - static const CONFIRM = const JsBeforeUnloadResponseAction._internal(0); - static const CANCEL = const JsBeforeUnloadResponseAction._internal(1); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents the response used by the [WebView.onJsBeforeUnload] event to control a JavaScript alert dialog. -class JsBeforeUnloadResponse { - ///Message to be displayed in the window. - String message; - - ///Title of the confirm button. - String confirmButtonTitle; - - ///Title of the cancel button. - String cancelButtonTitle; - - ///Whether the client will handle the alert dialog. - bool handledByClient; - - ///Action used to confirm that the user hit confirm button. - JsBeforeUnloadResponseAction? action; - - JsBeforeUnloadResponse( - {this.message = "", - this.handledByClient = false, - this.confirmButtonTitle = "", - this.cancelButtonTitle = "", - this.action = JsBeforeUnloadResponseAction.CONFIRM}); - - Map toMap() { - return { - "message": message, - "confirmButtonTitle": confirmButtonTitle, - "cancelButtonTitle": cancelButtonTitle, - "handledByClient": handledByClient, - "action": action?.toValue() - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents the reason the resource was caught by Safe Browsing. -class SafeBrowsingThreat { - final int _value; - - const SafeBrowsingThreat._internal(this._value); - - static final Set values = [ - SafeBrowsingThreat.SAFE_BROWSING_THREAT_UNKNOWN, - SafeBrowsingThreat.SAFE_BROWSING_THREAT_MALWARE, - SafeBrowsingThreat.SAFE_BROWSING_THREAT_PHISHING, - SafeBrowsingThreat.SAFE_BROWSING_THREAT_UNWANTED_SOFTWARE, - SafeBrowsingThreat.SAFE_BROWSING_THREAT_BILLING, - ].toSet(); - - static SafeBrowsingThreat? fromValue(int? value) { - if (value != null) { - try { - return SafeBrowsingThreat.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - - return null; - } - - int toValue() => _value; - - String toString() { - switch (_value) { - case 1: - return "SAFE_BROWSING_THREAT_MALWARE"; - case 2: - return "SAFE_BROWSING_THREAT_PHISHING"; - case 3: - return "SAFE_BROWSING_THREAT_UNWANTED_SOFTWARE"; - case 4: - return "SAFE_BROWSING_THREAT_BILLING"; - case 0: - default: - return "SAFE_BROWSING_THREAT_UNKNOWN"; - } - } - - static const SAFE_BROWSING_THREAT_UNKNOWN = - const SafeBrowsingThreat._internal(0); - static const SAFE_BROWSING_THREAT_MALWARE = - const SafeBrowsingThreat._internal(1); - static const SAFE_BROWSING_THREAT_PHISHING = - const SafeBrowsingThreat._internal(2); - static const SAFE_BROWSING_THREAT_UNWANTED_SOFTWARE = - const SafeBrowsingThreat._internal(3); - static const SAFE_BROWSING_THREAT_BILLING = - const SafeBrowsingThreat._internal(4); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class used by [SafeBrowsingResponse] class. -class SafeBrowsingResponseAction { - final int _value; - - const SafeBrowsingResponseAction._internal(this._value); - - int toValue() => _value; - - ///Act as if the user clicked the "back to safety" button. - static const BACK_TO_SAFETY = const SafeBrowsingResponseAction._internal(0); - - ///Act as if the user clicked the "visit this unsafe site" button. - static const PROCEED = const SafeBrowsingResponseAction._internal(1); - - ///Display the default interstitial. - static const SHOW_INTERSTITIAL = - const SafeBrowsingResponseAction._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents the response used by the [WebView.onSafeBrowsingHit] event. -///It is used to indicate an action to take when hitting a malicious URL. -class SafeBrowsingResponse { - ///If reporting is enabled, all reports will be sent according to the privacy policy referenced by [AndroidInAppWebViewController.getSafeBrowsingPrivacyPolicyUrl]. - bool report; - - ///Indicate the [SafeBrowsingResponseAction] to take when hitting a malicious URL. - SafeBrowsingResponseAction? action; - - SafeBrowsingResponse( - {this.report = true, - this.action = SafeBrowsingResponseAction.SHOW_INTERSTITIAL}); - - Map toMap() { - return {"report": report, "action": action?.toValue()}; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class used by [HttpAuthResponse] class. -class HttpAuthResponseAction { - final int _value; - - const HttpAuthResponseAction._internal(this._value); - - int toValue() => _value; - - ///Instructs the WebView to cancel the authentication request. - static const CANCEL = const HttpAuthResponseAction._internal(0); - - ///Instructs the WebView to proceed with the authentication with the given credentials. - static const PROCEED = const HttpAuthResponseAction._internal(1); - - ///Uses the credentials stored for the current host. - static const USE_SAVED_HTTP_AUTH_CREDENTIALS = - const HttpAuthResponseAction._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents the response used by the [WebView.onReceivedHttpAuthRequest] event. -class HttpAuthResponse { - ///Represents the username used for the authentication if the [action] corresponds to [HttpAuthResponseAction.PROCEED] - String username; - - ///Represents the password used for the authentication if the [action] corresponds to [HttpAuthResponseAction.PROCEED] - String password; - - ///Indicate if the given credentials need to be saved permanently. - bool permanentPersistence; - - ///Indicate the [HttpAuthResponseAction] to take in response of the authentication challenge. - HttpAuthResponseAction? action; - - HttpAuthResponse( - {this.username = "", - this.password = "", - this.permanentPersistence = false, - this.action = HttpAuthResponseAction.CANCEL}); - - Map toMap() { - return { - "username": username, - "password": password, - "permanentPersistence": permanentPersistence, - "action": action?.toValue() - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents the constants that specify how long the credential will be kept. -class URLCredentialPersistence { - final int _value; - - const URLCredentialPersistence._internal(this._value); - - static final Set values = [ - URLCredentialPersistence.NONE, - URLCredentialPersistence.FOR_SESSION, - URLCredentialPersistence.PERMANENT, - URLCredentialPersistence.SYNCHRONIZABLE, - ].toSet(); - - static URLCredentialPersistence? fromValue(int? value) { - if (value != null) { - try { - return URLCredentialPersistence.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - - return null; - } - - int toValue() => _value; - - String toString() { - switch (_value) { - case 1: - return "FOR_SESSION"; - case 2: - return "PERMANENT"; - case 3: - return "SYNCHRONIZABLE"; - case 0: - default: - return "NONE"; - } - } - - ///The credential should not be stored. - static const NONE = const URLCredentialPersistence._internal(0); - - ///The credential should be stored only for this session - static const FOR_SESSION = const URLCredentialPersistence._internal(1); - - ///The credential should be stored in the keychain. - static const PERMANENT = const URLCredentialPersistence._internal(2); - - ///The credential should be stored permanently in the keychain, - ///and in addition should be distributed to other devices based on the owning Apple ID. - static const SYNCHRONIZABLE = const URLCredentialPersistence._internal(3); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///An iOS-specific class that represents the constants that specify how long the credential will be kept. -///Use [URLCredentialPersistence] instead. -@Deprecated("Use URLCredentialPersistence instead") -class IOSURLCredentialPersistence { - final int _value; - - const IOSURLCredentialPersistence._internal(this._value); - - static final Set values = [ - IOSURLCredentialPersistence.NONE, - IOSURLCredentialPersistence.FOR_SESSION, - IOSURLCredentialPersistence.PERMANENT, - IOSURLCredentialPersistence.SYNCHRONIZABLE, - ].toSet(); - - static IOSURLCredentialPersistence? fromValue(int? value) { - if (value != null) { - try { - return IOSURLCredentialPersistence.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - - return null; - } - - int toValue() => _value; - - String toString() { - switch (_value) { - case 1: - return "FOR_SESSION"; - case 2: - return "PERMANENT"; - case 3: - return "SYNCHRONIZABLE"; - case 0: - default: - return "NONE"; - } - } - - ///The credential should not be stored. - static const NONE = const IOSURLCredentialPersistence._internal(0); - - ///The credential should be stored only for this session - static const FOR_SESSION = const IOSURLCredentialPersistence._internal(1); - - ///The credential should be stored in the keychain. - static const PERMANENT = const IOSURLCredentialPersistence._internal(2); - - ///The credential should be stored permanently in the keychain, - ///and in addition should be distributed to other devices based on the owning Apple ID. - static const SYNCHRONIZABLE = const IOSURLCredentialPersistence._internal(3); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents an authentication credential consisting of information -///specific to the type of credential and the type of persistent storage to use, if any. -class URLCredential { - ///The credential’s user name. - String? username; - - ///The credential’s password. - String? password; - - ///Use [certificates] instead. - @Deprecated("Use certificates instead") - List? iosCertificates; - - ///The intermediate certificates of the credential, if it is a client certificate credential. - /// - ///**NOTE**: available only on iOS. - List? certificates; - - ///Use [persistence] instead. - @Deprecated("Use persistence instead") - IOSURLCredentialPersistence? iosPersistence; - - ///The credential’s persistence setting. - /// - ///**NOTE**: available only on iOS. - URLCredentialPersistence? persistence; - - URLCredential( - {this.username, - this.password, - @Deprecated("Use certificates instead") this.iosPersistence, - this.persistence, - @Deprecated("Use persistence instead") this.iosCertificates, - this.certificates}) { - // ignore: deprecated_member_use_from_same_package - this.persistence = this.persistence ?? - // ignore: deprecated_member_use_from_same_package - URLCredentialPersistence.fromValue(this.iosPersistence?.toValue()); - // ignore: deprecated_member_use_from_same_package - this.certificates = this.certificates ?? this.iosCertificates; - } - - Map toMap() { - return { - "username": username, - "password": password, - "iosCertificates": - // ignore: deprecated_member_use_from_same_package - (certificates ?? iosCertificates)?.map((e) => e.toMap()).toList(), - "certificates": - // ignore: deprecated_member_use_from_same_package - (certificates ?? iosCertificates)?.map((e) => e.toMap()).toList(), - // ignore: deprecated_member_use_from_same_package - "iosPersistence": persistence?.toValue() ?? iosPersistence?.toValue(), - // ignore: deprecated_member_use_from_same_package - "persistence": persistence?.toValue() ?? iosPersistence?.toValue(), - }; - } - - static URLCredential? fromMap(Map? map) { - if (map == null) { - return null; - } - - List? certificates; - if (map["certificates"] != null) { - certificates = []; - (map["certificates"].cast() as List) - .forEach((data) { - try { - certificates!.add(X509Certificate.fromData(data: data)); - } catch (e, stacktrace) { - print(e); - print(stacktrace); - } - }); - } - - return URLCredential( - username: map["user"], - password: map["password"], - // ignore: deprecated_member_use_from_same_package - iosCertificates: certificates, - certificates: certificates, - persistence: URLCredentialPersistence.fromValue(map["persistence"]), - // ignore: deprecated_member_use_from_same_package - iosPersistence: - // ignore: deprecated_member_use_from_same_package - IOSURLCredentialPersistence.fromValue(map["persistence"])); - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents a challenge from a server requiring authentication from the client. -///It provides all the information about the challenge. -class URLAuthenticationChallenge { - ///The protection space requiring authentication. - URLProtectionSpace protectionSpace; - - URLAuthenticationChallenge({ - required this.protectionSpace, - }); - - Map toMap() { - return { - "protectionSpace": protectionSpace.toMap(), - }; - } - - static URLAuthenticationChallenge? fromMap(Map? map) { - if (map == null) { - return null; - } - return URLAuthenticationChallenge( - protectionSpace: URLProtectionSpace.fromMap( - map["protectionSpace"].cast())!, - ); - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents the challenge of the [WebView.onReceivedHttpAuthRequest] event. -///It provides all the information about the challenge. -class HttpAuthenticationChallenge extends URLAuthenticationChallenge { - ///A count of previous failed authentication attempts. - int previousFailureCount; - - ///The proposed credential for this challenge. - ///This method returns `null` if there is no default credential for this challenge. - ///If you have previously attempted to authenticate and failed, this method returns the most recent failed credential. - ///If the proposed credential is not nil and returns true when you call its hasPassword method, then the credential is ready to use as-is. - ///If the proposed credential’s hasPassword method returns false, then the credential provides a default user name, - ///and the client must prompt the user for a corresponding password. - URLCredential? proposedCredential; - - ///Use [failureResponse] instead. - @Deprecated("Use failureResponse instead") - IOSURLResponse? iosFailureResponse; - - ///The URL response object representing the last authentication failure. - ///This value is `null` if the protocol doesn’t use responses to indicate an authentication failure. - /// - ///**NOTE**: available only on iOS. - URLResponse? failureResponse; - - ///Use [error] instead. - @Deprecated("Use error instead") - String? iosError; - - ///The error object representing the last authentication failure. - ///This value is `null` if the protocol doesn’t use errors to indicate an authentication failure. - /// - ///**NOTE**: available only on iOS. - String? error; - - HttpAuthenticationChallenge( - {required this.previousFailureCount, - required URLProtectionSpace protectionSpace, - @Deprecated("Use failureResponse instead") this.iosFailureResponse, - this.failureResponse, - this.proposedCredential, - @Deprecated("Use error instead") this.iosError, - this.error}) - : super(protectionSpace: protectionSpace) { - this.failureResponse = this.failureResponse ?? - // ignore: deprecated_member_use_from_same_package - URLResponse.fromMap(this.iosFailureResponse?.toMap()); - // ignore: deprecated_member_use_from_same_package - this.error = this.error ?? this.iosError; - } - - Map toMap() { - var map = super.toMap(); - map.addAll({ - "previousFailureCount": previousFailureCount, - "protectionSpace": protectionSpace.toMap(), - "proposedCredential": proposedCredential?.toMap(), - "iosFailureResponse": - // ignore: deprecated_member_use_from_same_package - failureResponse?.toMap() ?? iosFailureResponse?.toMap(), - "failureResponse": - // ignore: deprecated_member_use_from_same_package - failureResponse?.toMap() ?? iosFailureResponse?.toMap(), - // ignore: deprecated_member_use_from_same_package - "iosError": error ?? iosError, - // ignore: deprecated_member_use_from_same_package - "error": error ?? iosError, - }); - return map; - } - - static HttpAuthenticationChallenge? fromMap(Map? map) { - if (map == null) { - return null; - } - return HttpAuthenticationChallenge( - previousFailureCount: map["previousFailureCount"], - protectionSpace: URLProtectionSpace.fromMap( - map["protectionSpace"].cast())!, - proposedCredential: URLCredential.fromMap( - map["proposedCredential"]?.cast()), - // ignore: deprecated_member_use_from_same_package - iosFailureResponse: IOSURLResponse.fromMap( - map["failureResponse"]?.cast()), - failureResponse: - URLResponse.fromMap(map["failureResponse"]?.cast()), - // ignore: deprecated_member_use_from_same_package - iosError: map["error"], - error: map["error"], - ); - } -} - -///Class that represents the challenge of the [WebView.onReceivedServerTrustAuthRequest] event. -///It provides all the information about the challenge. -class ServerTrustChallenge extends URLAuthenticationChallenge { - ServerTrustChallenge({required URLProtectionSpace protectionSpace}) - : super(protectionSpace: protectionSpace); - - static ServerTrustChallenge? fromMap(Map? map) { - if (map == null) { - return null; - } - return ServerTrustChallenge( - protectionSpace: URLProtectionSpace.fromMap( - map["protectionSpace"].cast())!, - ); - } -} - -///Class that represents the challenge of the [WebView.onReceivedClientCertRequest] event. -///It provides all the information about the challenge. -class ClientCertChallenge extends URLAuthenticationChallenge { - ///Use [principals] instead. - @Deprecated('Use principals instead') - List? androidPrincipals; - - ///The acceptable certificate issuers for the certificate matching the private key. - /// - ///**NOTE**: available only on Android. - List? principals; - - ///Use [keyTypes] instead. - @Deprecated('Use keyTypes instead') - List? androidKeyTypes; - - ///Returns the acceptable types of asymmetric keys. - /// - ///**NOTE**: available only on Android. - List? keyTypes; - - ClientCertChallenge( - {required URLProtectionSpace protectionSpace, - @Deprecated('Use principals instead') this.androidPrincipals, - this.principals, - @Deprecated('Use keyTypes instead') this.androidKeyTypes, - this.keyTypes}) - : super(protectionSpace: protectionSpace) { - // ignore: deprecated_member_use_from_same_package - this.principals = this.principals ?? this.androidPrincipals; - // ignore: deprecated_member_use_from_same_package - this.keyTypes = this.keyTypes ?? this.androidKeyTypes; - } - - static ClientCertChallenge? fromMap(Map? map) { - if (map == null) { - return null; - } - return ClientCertChallenge( - protectionSpace: URLProtectionSpace.fromMap( - map["protectionSpace"].cast())!, - // ignore: deprecated_member_use_from_same_package - androidPrincipals: map["principals"]?.cast(), - principals: map["principals"]?.cast(), - // ignore: deprecated_member_use_from_same_package - androidKeyTypes: map["keyTypes"]?.cast(), - keyTypes: map["keyTypes"]?.cast()); - } -} - -///An iOS-specific Class that represents the supported proxy types. -class URLProtectionSpaceProxyType { - final String _value; - - const URLProtectionSpaceProxyType._internal(this._value); - - static final Set values = [ - URLProtectionSpaceProxyType.NSUR_PROTECTION_SPACE_HTTP_PROXY, - URLProtectionSpaceProxyType.NSURL_PROTECTION_SPACE_HTTPS_PROXY, - URLProtectionSpaceProxyType.NSURL_PROTECTION_SPACE_FTP_PROXY, - URLProtectionSpaceProxyType.NSURL_PROTECTION_SPACE_SOCKS_PROXY, - ].toSet(); - - static URLProtectionSpaceProxyType? fromValue(String? value) { - if (value != null) { - try { - return URLProtectionSpaceProxyType.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - String toValue() => _value; - - @override - String toString() => _value; - - ///The proxy type for HTTP proxies. - static const NSUR_PROTECTION_SPACE_HTTP_PROXY = - const URLProtectionSpaceProxyType._internal( - "NSURLProtectionSpaceHTTPProxy"); - - ///The proxy type for HTTPS proxies. - static const NSURL_PROTECTION_SPACE_HTTPS_PROXY = - const URLProtectionSpaceProxyType._internal( - "NSURLProtectionSpaceHTTPSProxy"); - - ///The proxy type for FTP proxies. - static const NSURL_PROTECTION_SPACE_FTP_PROXY = - const URLProtectionSpaceProxyType._internal( - "NSURLProtectionSpaceFTPProxy"); - - ///The proxy type for SOCKS proxies. - static const NSURL_PROTECTION_SPACE_SOCKS_PROXY = - const URLProtectionSpaceProxyType._internal( - "NSURLProtectionSpaceSOCKSProxy"); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///An iOS-specific Class that represents the supported proxy types. -///Use [URLProtectionSpaceProxyType] instead. -@Deprecated("Use URLProtectionSpaceProxyType instead") -class IOSNSURLProtectionSpaceProxyType { - final String _value; - - const IOSNSURLProtectionSpaceProxyType._internal(this._value); - - static final Set values = [ - IOSNSURLProtectionSpaceProxyType.NSUR_PROTECTION_SPACE_HTTP_PROXY, - IOSNSURLProtectionSpaceProxyType.NSURL_PROTECTION_SPACE_HTTPS_PROXY, - IOSNSURLProtectionSpaceProxyType.NSURL_PROTECTION_SPACE_FTP_PROXY, - IOSNSURLProtectionSpaceProxyType.NSURL_PROTECTION_SPACE_SOCKS_PROXY, - ].toSet(); - - static IOSNSURLProtectionSpaceProxyType? fromValue(String? value) { - if (value != null) { - try { - return IOSNSURLProtectionSpaceProxyType.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - String toValue() => _value; - - @override - String toString() => _value; - - ///The proxy type for HTTP proxies. - static const NSUR_PROTECTION_SPACE_HTTP_PROXY = - const IOSNSURLProtectionSpaceProxyType._internal( - "NSURLProtectionSpaceHTTPProxy"); - - ///The proxy type for HTTPS proxies. - static const NSURL_PROTECTION_SPACE_HTTPS_PROXY = - const IOSNSURLProtectionSpaceProxyType._internal( - "NSURLProtectionSpaceHTTPSProxy"); - - ///The proxy type for FTP proxies. - static const NSURL_PROTECTION_SPACE_FTP_PROXY = - const IOSNSURLProtectionSpaceProxyType._internal( - "NSURLProtectionSpaceFTPProxy"); - - ///The proxy type for SOCKS proxies. - static const NSURL_PROTECTION_SPACE_SOCKS_PROXY = - const IOSNSURLProtectionSpaceProxyType._internal( - "NSURLProtectionSpaceSOCKSProxy"); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///An iOS-specific Class that represents the constants describing known values of the [URLProtectionSpace.authenticationMethod] property. -class URLProtectionSpaceAuthenticationMethod { - final String _value; - - const URLProtectionSpaceAuthenticationMethod._internal(this._value); - - static final Set values = [ - URLProtectionSpaceAuthenticationMethod - .NSURL_AUTHENTICATION_METHOD_CLIENT_CERTIFICATE, - URLProtectionSpaceAuthenticationMethod - .NSURL_AUTHENTICATION_METHOD_NEGOTIATE, - URLProtectionSpaceAuthenticationMethod.NSURL_AUTHENTICATION_METHOD_NTLM, - URLProtectionSpaceAuthenticationMethod - .NSURL_AUTHENTICATION_METHOD_SERVER_TRUST, - ].toSet(); - - static URLProtectionSpaceAuthenticationMethod? fromValue(String? value) { - if (value != null) { - try { - return URLProtectionSpaceAuthenticationMethod.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - String toValue() => _value; - - @override - String toString() => _value; - - ///Use client certificate authentication for this protection space. - static const NSURL_AUTHENTICATION_METHOD_CLIENT_CERTIFICATE = - const URLProtectionSpaceAuthenticationMethod._internal( - "NSURLAuthenticationMethodClientCertificate"); - - ///Negotiate whether to use Kerberos or NTLM authentication for this protection space. - static const NSURL_AUTHENTICATION_METHOD_NEGOTIATE = - const URLProtectionSpaceAuthenticationMethod._internal( - "NSURLAuthenticationMethodNegotiate"); - - ///Use NTLM authentication for this protection space. - static const NSURL_AUTHENTICATION_METHOD_NTLM = - const URLProtectionSpaceAuthenticationMethod._internal( - "NSURLAuthenticationMethodNTLM"); - - ///Perform server trust authentication (certificate validation) for this protection space. - static const NSURL_AUTHENTICATION_METHOD_SERVER_TRUST = - const URLProtectionSpaceAuthenticationMethod._internal( - "NSURLAuthenticationMethodServerTrust"); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///An iOS-specific Class that represents the constants describing known values of the [URLProtectionSpace.authenticationMethod] property. -///Use [URLProtectionSpaceAuthenticationMethod] instead. -@Deprecated("Use URLProtectionSpaceAuthenticationMethod instead") -class IOSNSURLProtectionSpaceAuthenticationMethod { - final String _value; - - const IOSNSURLProtectionSpaceAuthenticationMethod._internal(this._value); - - static final Set values = [ - IOSNSURLProtectionSpaceAuthenticationMethod - .NSURL_AUTHENTICATION_METHOD_CLIENT_CERTIFICATE, - IOSNSURLProtectionSpaceAuthenticationMethod - .NSURL_AUTHENTICATION_METHOD_NEGOTIATE, - IOSNSURLProtectionSpaceAuthenticationMethod - .NSURL_AUTHENTICATION_METHOD_NTLM, - IOSNSURLProtectionSpaceAuthenticationMethod - .NSURL_AUTHENTICATION_METHOD_SERVER_TRUST, - ].toSet(); - - static IOSNSURLProtectionSpaceAuthenticationMethod? fromValue(String? value) { - if (value != null) { - try { - return IOSNSURLProtectionSpaceAuthenticationMethod.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - String toValue() => _value; - - @override - String toString() => _value; - - ///Use client certificate authentication for this protection space. - static const NSURL_AUTHENTICATION_METHOD_CLIENT_CERTIFICATE = - const IOSNSURLProtectionSpaceAuthenticationMethod._internal( - "NSURLAuthenticationMethodClientCertificate"); - - ///Negotiate whether to use Kerberos or NTLM authentication for this protection space. - static const NSURL_AUTHENTICATION_METHOD_NEGOTIATE = - const IOSNSURLProtectionSpaceAuthenticationMethod._internal( - "NSURLAuthenticationMethodNegotiate"); - - ///Use NTLM authentication for this protection space. - static const NSURL_AUTHENTICATION_METHOD_NTLM = - const IOSNSURLProtectionSpaceAuthenticationMethod._internal( - "NSURLAuthenticationMethodNTLM"); - - ///Perform server trust authentication (certificate validation) for this protection space. - static const NSURL_AUTHENTICATION_METHOD_SERVER_TRUST = - const IOSNSURLProtectionSpaceAuthenticationMethod._internal( - "NSURLAuthenticationMethodServerTrust"); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents an SSL Error. -class SslError { - ///Use [code] instead. - @Deprecated('Use code instead') - AndroidSslError? androidError; - - ///Use [code] instead. - @Deprecated('Use code instead') - IOSSslError? iosError; - - ///Primary code error associated to the server SSL certificate. - ///It represents the most severe SSL error. - SslErrorType? code; - - ///The message associated to the [code]. - String? message; - - SslError( - {@Deprecated('Use code instead') this.androidError, - @Deprecated('Use code instead') this.iosError, - this.code, - this.message}) { - this.code = this.code ?? - // ignore: deprecated_member_use_from_same_package - SslErrorType.fromValue(this.androidError?.toValue() ?? - // ignore: deprecated_member_use_from_same_package - this.iosError?.toValue()); - } - - static SslError? fromMap(Map? map) { - if (map == null) { - return null; - } - return SslError( - // ignore: deprecated_member_use_from_same_package - androidError: AndroidSslError.fromValue(map["code"]), - // ignore: deprecated_member_use_from_same_package - iosError: IOSSslError.fromValue(map["code"]), - code: SslErrorType.fromValue(map["code"]), - message: map["message"]); - } - - Map toMap() { - return { - // ignore: deprecated_member_use_from_same_package - "androidError": code?.toValue() ?? androidError?.toValue(), - // ignore: deprecated_member_use_from_same_package - "iosError": code?.toValue() ?? iosError?.toValue(), - // ignore: deprecated_member_use_from_same_package - "code": code?.toValue() ?? androidError?.toValue() ?? iosError?.toValue(), - "message": message, - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents a protection space requiring authentication. -class URLProtectionSpace { - ///The hostname of the server. - String host; - - ///The protocol of the server - e.g. "http", "ftp", "https". - String? protocol; - - ///A string indicating a protocol-specific subdivision of a single host. - ///For http and https, this maps to the realm string in http authentication challenges. - ///For many other protocols it is unused. - String? realm; - - ///The port of the server. - int? port; - - ///The SSL certificate used. - SslCertificate? sslCertificate; - - ///The SSL Error associated. - SslError? sslError; - - ///Use [authenticationMethod] instead. - @Deprecated("Use authenticationMethod instead") - IOSNSURLProtectionSpaceAuthenticationMethod? iosAuthenticationMethod; - - ///The authentication method used by the receiver. - /// - ///**NOTE**: available only on iOS. - URLProtectionSpaceAuthenticationMethod? authenticationMethod; - - ///Use [distinguishedNames] instead. - @Deprecated("Use distinguishedNames instead") - List? iosDistinguishedNames; - - ///The acceptable certificate-issuing authorities for client certificate authentication. - ///This value is `null` if the authentication method of the protection space is not client certificate. - ///The returned issuing authorities are encoded with Distinguished Encoding Rules (DER). - /// - ///**NOTE**: available only on iOS. - List? distinguishedNames; - - ///Use [receivesCredentialSecurely] instead. - @Deprecated("Use receivesCredentialSecurely instead") - bool? iosReceivesCredentialSecurely; - - ///A Boolean value that indicates whether the credentials for the protection space can be sent securely. - ///This value is `true` if the credentials for the protection space represented by the receiver can be sent securely, `false` otherwise. - /// - ///**NOTE**: available only on iOS. - bool? receivesCredentialSecurely; - - ///Use [isProxy] instead. - @Deprecated("Use isProxy instead") - bool? iosIsProxy; - - ///Returns a Boolean value that indicates whether the receiver does not descend from `NSObject`. - /// - ///**NOTE**: available only on iOS. - bool? isProxy; - - ///Use [proxyType] instead. - @Deprecated("Use proxyType instead") - IOSNSURLProtectionSpaceProxyType? iosProxyType; - - ///The receiver's proxy type. - ///This value is `null` if the receiver does not represent a proxy protection space. - ///The supported proxy types are listed in [URLProtectionSpaceProxyType.values]. - /// - ///**NOTE**: available only on iOS. - URLProtectionSpaceProxyType? proxyType; - - URLProtectionSpace( - {required this.host, - this.protocol, - this.realm, - this.port, - this.sslCertificate, - this.sslError, - @Deprecated("Use authenticationMethod instead") - this.iosAuthenticationMethod, - this.authenticationMethod, - @Deprecated("Use distinguishedNames instead") - this.iosDistinguishedNames, - this.distinguishedNames, - @Deprecated("Use receivesCredentialSecurely instead") - this.iosReceivesCredentialSecurely, - this.receivesCredentialSecurely, - @Deprecated("Use isProxy instead") - this.iosIsProxy, - this.isProxy, - @Deprecated("Use proxyType instead") - this.iosProxyType, - this.proxyType}) { - this.authenticationMethod = this.authenticationMethod ?? - URLProtectionSpaceAuthenticationMethod.fromValue( - // ignore: deprecated_member_use_from_same_package - this.iosAuthenticationMethod?.toValue()); - this.distinguishedNames = - // ignore: deprecated_member_use_from_same_package - this.distinguishedNames ?? this.iosDistinguishedNames; - this.receivesCredentialSecurely = - // ignore: deprecated_member_use_from_same_package - this.receivesCredentialSecurely ?? this.iosReceivesCredentialSecurely; - // ignore: deprecated_member_use_from_same_package - this.isProxy = this.isProxy ?? this.iosIsProxy; - this.proxyType = this.proxyType ?? - // ignore: deprecated_member_use_from_same_package - URLProtectionSpaceProxyType.fromValue(this.iosProxyType?.toValue()); - } - - static URLProtectionSpace? fromMap(Map? map) { - if (map == null) { - return null; - } - List? distinguishedNames; - if (map["distinguishedNames"] != null) { - distinguishedNames = []; - (map["distinguishedNames"].cast() as List) - .forEach((data) { - try { - distinguishedNames!.add(X509Certificate.fromData(data: data)); - } catch (e, stacktrace) { - print(e); - print(stacktrace); - } - }); - } - - return URLProtectionSpace( - host: map["host"], - protocol: map["protocol"], - realm: map["realm"], - port: map["port"], - sslCertificate: SslCertificate.fromMap( - map["sslCertificate"]?.cast()), - sslError: SslError.fromMap(map["sslError"]?.cast()), - // ignore: deprecated_member_use_from_same_package - iosAuthenticationMethod: - // ignore: deprecated_member_use_from_same_package - IOSNSURLProtectionSpaceAuthenticationMethod.fromValue( - map["authenticationMethod"]), - authenticationMethod: URLProtectionSpaceAuthenticationMethod.fromValue( - map["authenticationMethod"]), - // ignore: deprecated_member_use_from_same_package - iosDistinguishedNames: distinguishedNames, - distinguishedNames: distinguishedNames, - // ignore: deprecated_member_use_from_same_package - iosReceivesCredentialSecurely: map["receivesCredentialSecurely"], - receivesCredentialSecurely: map["receivesCredentialSecurely"], - // ignore: deprecated_member_use_from_same_package - iosIsProxy: map["isProxy"], - isProxy: map["isProxy"], - // ignore: deprecated_member_use_from_same_package - iosProxyType: - // ignore: deprecated_member_use_from_same_package - IOSNSURLProtectionSpaceProxyType.fromValue(map["proxyType"]), - proxyType: URLProtectionSpaceProxyType.fromValue(map["proxyType"]), - ); - } - - Map toMap() { - return { - "host": host, - "protocol": protocol, - "realm": realm, - "port": port, - "sslCertificate": sslCertificate?.toMap(), - "sslError": sslError?.toMap(), - "iosAuthenticationMethod": - // ignore: deprecated_member_use_from_same_package - authenticationMethod ?? iosAuthenticationMethod, - // ignore: deprecated_member_use_from_same_package - "authenticationMethod": authenticationMethod ?? iosAuthenticationMethod, - // ignore: deprecated_member_use_from_same_package - "iosDistinguishedNames": (distinguishedNames ?? iosDistinguishedNames) - ?.map((e) => e.toMap()) - .toList(), - // ignore: deprecated_member_use_from_same_package - "distinguishedNames": (distinguishedNames ?? iosDistinguishedNames) - ?.map((e) => e.toMap()) - .toList(), - "iosReceivesCredentialSecurely": - // ignore: deprecated_member_use_from_same_package - receivesCredentialSecurely ?? iosReceivesCredentialSecurely, - "receivesCredentialSecurely": - // ignore: deprecated_member_use_from_same_package - receivesCredentialSecurely ?? iosReceivesCredentialSecurely, - // ignore: deprecated_member_use_from_same_package - "iosIsProxy": isProxy ?? iosIsProxy, - // ignore: deprecated_member_use_from_same_package - "isProxy": isProxy ?? iosIsProxy, - // ignore: deprecated_member_use_from_same_package - "iosProxyType": proxyType?.toValue() ?? iosProxyType?.toValue(), - // ignore: deprecated_member_use_from_same_package - "proxyType": proxyType?.toValue() ?? iosProxyType?.toValue(), - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents a [URLProtectionSpace] with all of its [HttpAuthCredential]s. -///It used by [HttpAuthCredentialDatabase.getAllAuthCredentials]. -class URLProtectionSpaceHttpAuthCredentials { - ///The protection space. - URLProtectionSpace? protectionSpace; - - ///The list of all its http authentication credentials. - List? credentials; - - URLProtectionSpaceHttpAuthCredentials( - {this.protectionSpace, this.credentials}); - - static URLProtectionSpaceHttpAuthCredentials? fromMap( - Map? map) { - if (map == null) { - return null; - } - - List? credentials; - if (map["credentials"] != null) { - credentials = []; - (map["credentials"].cast>() - as List>) - .forEach((element) { - var credential = URLCredential.fromMap(element); - if (credential != null) { - credentials!.add(credential); - } - }); - } - - return URLProtectionSpaceHttpAuthCredentials( - protectionSpace: map["protectionSpace"] != null - ? URLProtectionSpace.fromMap( - map["protectionSpace"]?.cast()) - : null, - credentials: credentials, - ); - } - - Map toMap() { - return { - "protectionSpace": protectionSpace?.toMap(), - "credentials": credentials != null - ? credentials!.map((credential) => credential.toMap()).toList() - : null - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class used by [ServerTrustAuthResponse] class. -class ServerTrustAuthResponseAction { - final int _value; - - const ServerTrustAuthResponseAction._internal(this._value); - - int toValue() => _value; - - ///Instructs the WebView to cancel the authentication challenge. - static const CANCEL = const ServerTrustAuthResponseAction._internal(0); - - ///Instructs the WebView to proceed with the authentication challenge. - static const PROCEED = const ServerTrustAuthResponseAction._internal(1); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///ServerTrustAuthResponse class represents the response used by the [WebView.onReceivedServerTrustAuthRequest] event. -class ServerTrustAuthResponse { - ///Indicate the [ServerTrustAuthResponseAction] to take in response of the server trust authentication challenge. - ServerTrustAuthResponseAction? action; - - ServerTrustAuthResponse({this.action = ServerTrustAuthResponseAction.CANCEL}); - - Map toMap() { - return {"action": action?.toValue()}; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class used by [ClientCertResponse] class. -class ClientCertResponseAction { - final int _value; - - const ClientCertResponseAction._internal(this._value); - - int toValue() => _value; - - ///Cancel this request. - static const CANCEL = const ClientCertResponseAction._internal(0); - - ///Proceed with the specified certificate. - static const PROCEED = const ClientCertResponseAction._internal(1); - - ///Ignore the request for now. - static const IGNORE = const ClientCertResponseAction._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents the response used by the [WebView.onReceivedClientCertRequest] event. -class ClientCertResponse { - ///The file path of the certificate to use. - String certificatePath; - - ///The certificate password. - String? certificatePassword; - - ///Use [keyStoreType] instead. - @Deprecated('Use keyStoreType instead') - String? androidKeyStoreType; - - ///An Android-specific property used by Java [KeyStore](https://developer.android.com/reference/java/security/KeyStore) class to get the instance. - String? keyStoreType; - - ///Indicate the [ClientCertResponseAction] to take in response of the client certificate challenge. - ClientCertResponseAction? action; - - ClientCertResponse( - {required this.certificatePath, - this.certificatePassword = "", - @Deprecated('Use keyStoreType instead') - this.androidKeyStoreType = "PKCS12", - this.keyStoreType = "PKCS12", - this.action = ClientCertResponseAction.CANCEL}) { - if (this.action == ClientCertResponseAction.PROCEED) - assert(certificatePath.isNotEmpty); - // ignore: deprecated_member_use_from_same_package - this.keyStoreType = this.keyStoreType ?? this.androidKeyStoreType; - } - - Map toMap() { - return { - "certificatePath": certificatePath, - "certificatePassword": certificatePassword, - // ignore: deprecated_member_use_from_same_package - "androidKeyStoreType": keyStoreType ?? androidKeyStoreType, - // ignore: deprecated_member_use_from_same_package - "keyStoreType": keyStoreType ?? androidKeyStoreType, - "action": action?.toValue() - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents a favicon of a website. It is used by [InAppWebViewController.getFavicons] method. -class Favicon { - ///The url of the favicon image. - Uri url; - - ///The relationship between the current web page and the favicon image. - String? rel; - - ///The width of the favicon image. - int? width; - - ///The height of the favicon image. - int? height; - - Favicon({required this.url, this.rel, this.width, this.height}); - - Map toMap() { - return { - "url": url.toString(), - "rel": rel, - "width": width, - "height": height - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class used to override the way the cache is used. -class CacheMode { - final int _value; - - const CacheMode._internal(this._value); - - static final Set values = [ - CacheMode.LOAD_DEFAULT, - CacheMode.LOAD_CACHE_ELSE_NETWORK, - CacheMode.LOAD_NO_CACHE, - CacheMode.LOAD_CACHE_ONLY, - ].toSet(); - - static CacheMode? fromValue(int? value) { - if (value != null) { - try { - return CacheMode.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "LOAD_CACHE_ELSE_NETWORK"; - case 2: - return "LOAD_NO_CACHE"; - case 3: - return "LOAD_CACHE_ONLY"; - case -1: - default: - return "LOAD_DEFAULT"; - } - } - - ///Default cache usage mode. If the navigation type doesn't impose any specific behavior, - ///use cached resources when they are available and not expired, otherwise load resources from the network. - static const LOAD_DEFAULT = const CacheMode._internal(-1); - - ///Use cached resources when they are available, even if they have expired. Otherwise load resources from the network. - static const LOAD_CACHE_ELSE_NETWORK = const CacheMode._internal(1); - - ///Don't use the cache, load from the network. - static const LOAD_NO_CACHE = const CacheMode._internal(2); - - ///Don't use the network, load from the cache. - static const LOAD_CACHE_ONLY = const CacheMode._internal(3); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///An Android-specific class used to override the way the cache is used. -///Use [CacheMode] instead. -@Deprecated("Use CacheMode instead") -class AndroidCacheMode { - final int _value; - - const AndroidCacheMode._internal(this._value); - - static final Set values = [ - AndroidCacheMode.LOAD_DEFAULT, - AndroidCacheMode.LOAD_CACHE_ELSE_NETWORK, - AndroidCacheMode.LOAD_NO_CACHE, - AndroidCacheMode.LOAD_CACHE_ONLY, - ].toSet(); - - static AndroidCacheMode? fromValue(int? value) { - if (value != null) { - try { - return AndroidCacheMode.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "LOAD_CACHE_ELSE_NETWORK"; - case 2: - return "LOAD_NO_CACHE"; - case 3: - return "LOAD_CACHE_ONLY"; - case -1: - default: - return "LOAD_DEFAULT"; - } - } - - ///Default cache usage mode. If the navigation type doesn't impose any specific behavior, - ///use cached resources when they are available and not expired, otherwise load resources from the network. - static const LOAD_DEFAULT = const AndroidCacheMode._internal(-1); - - ///Use cached resources when they are available, even if they have expired. Otherwise load resources from the network. - static const LOAD_CACHE_ELSE_NETWORK = const AndroidCacheMode._internal(1); - - ///Don't use the cache, load from the network. - static const LOAD_NO_CACHE = const AndroidCacheMode._internal(2); - - ///Don't use the network, load from the cache. - static const LOAD_CACHE_ONLY = const AndroidCacheMode._internal(3); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class used to disable the action mode menu items. -/// -///**NOTE**: available on Android 24+. -class ActionModeMenuItem { - final int _value; - - const ActionModeMenuItem._internal(this._value); - - static final Set values = [ - ActionModeMenuItem.MENU_ITEM_NONE, - ActionModeMenuItem.MENU_ITEM_SHARE, - ActionModeMenuItem.MENU_ITEM_WEB_SEARCH, - ActionModeMenuItem.MENU_ITEM_PROCESS_TEXT, - ].toSet(); - - static ActionModeMenuItem? fromValue(int? value) { - if (value != null) { - try { - return ActionModeMenuItem.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - // maybe coming from a Bitwise OR operator - return ActionModeMenuItem._internal(value); - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "MENU_ITEM_SHARE"; - case 2: - return "MENU_ITEM_WEB_SEARCH"; - case 4: - return "MENU_ITEM_PROCESS_TEXT"; - case 0: - return "MENU_ITEM_NONE"; - } - return _value.toString(); - } - - ///No menu items should be disabled. - static const MENU_ITEM_NONE = const ActionModeMenuItem._internal(0); - - ///Disable menu item "Share". - static const MENU_ITEM_SHARE = const ActionModeMenuItem._internal(1); - - ///Disable menu item "Web Search". - static const MENU_ITEM_WEB_SEARCH = const ActionModeMenuItem._internal(2); - - ///Disable all the action mode menu items for text processing. - static const MENU_ITEM_PROCESS_TEXT = const ActionModeMenuItem._internal(4); - - bool operator ==(value) => value == _value; - - ActionModeMenuItem operator |(ActionModeMenuItem value) => - ActionModeMenuItem._internal(value.toValue() | _value); - - @override - int get hashCode => _value.hashCode; -} - -///An Android-specific class used to disable the action mode menu items. -/// -///**NOTE**: available on Android 24+. -/// -///Use [ActionModeMenuItem] instead. -@Deprecated("Use ActionModeMenuItem instead") -class AndroidActionModeMenuItem { - final int _value; - - const AndroidActionModeMenuItem._internal(this._value); - - static final Set values = [ - AndroidActionModeMenuItem.MENU_ITEM_NONE, - AndroidActionModeMenuItem.MENU_ITEM_SHARE, - AndroidActionModeMenuItem.MENU_ITEM_WEB_SEARCH, - AndroidActionModeMenuItem.MENU_ITEM_PROCESS_TEXT, - ].toSet(); - - static AndroidActionModeMenuItem? fromValue(int? value) { - if (value != null) { - try { - return AndroidActionModeMenuItem.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - // maybe coming from a Bitwise OR operator - return AndroidActionModeMenuItem._internal(value); - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "MENU_ITEM_SHARE"; - case 2: - return "MENU_ITEM_WEB_SEARCH"; - case 4: - return "MENU_ITEM_PROCESS_TEXT"; - case 0: - return "MENU_ITEM_NONE"; - } - return _value.toString(); - } - - ///No menu items should be disabled. - static const MENU_ITEM_NONE = const AndroidActionModeMenuItem._internal(0); - - ///Disable menu item "Share". - static const MENU_ITEM_SHARE = const AndroidActionModeMenuItem._internal(1); - - ///Disable menu item "Web Search". - static const MENU_ITEM_WEB_SEARCH = - const AndroidActionModeMenuItem._internal(2); - - ///Disable all the action mode menu items for text processing. - static const MENU_ITEM_PROCESS_TEXT = - const AndroidActionModeMenuItem._internal(4); - - bool operator ==(value) => value == _value; - - AndroidActionModeMenuItem operator |(AndroidActionModeMenuItem value) => - AndroidActionModeMenuItem._internal(value.toValue() | _value); - - @override - int get hashCode => _value.hashCode; -} - -///Class used to indicate the force dark mode. -/// -///**NOTE**: available on Android 29+. -class ForceDark { - final int _value; - - const ForceDark._internal(this._value); - - static final Set values = [ - ForceDark.FORCE_DARK_OFF, - ForceDark.FORCE_DARK_AUTO, - ForceDark.FORCE_DARK_ON, - ].toSet(); - - static ForceDark? fromValue(int? value) { - if (value != null) { - try { - return ForceDark.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "FORCE_DARK_AUTO"; - case 2: - return "FORCE_DARK_ON"; - case 0: - default: - return "FORCE_DARK_OFF"; - } - } - - ///Disable force dark, irrespective of the force dark mode of the WebView parent. - ///In this mode, WebView content will always be rendered as-is, regardless of whether native views are being automatically darkened. - static const FORCE_DARK_OFF = const ForceDark._internal(0); - - ///Enable force dark dependent on the state of the WebView parent view. - static const FORCE_DARK_AUTO = const ForceDark._internal(1); - - ///Unconditionally enable force dark. In this mode WebView content will always be rendered so as to emulate a dark theme. - static const FORCE_DARK_ON = const ForceDark._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///An Android-specific class used to indicate the force dark mode. -/// -///**NOTE**: available on Android 29+. -/// -///Use [ForceDark] instead. -@Deprecated("Use ForceDark instead") -class AndroidForceDark { - final int _value; - - const AndroidForceDark._internal(this._value); - - static final Set values = [ - AndroidForceDark.FORCE_DARK_OFF, - AndroidForceDark.FORCE_DARK_AUTO, - AndroidForceDark.FORCE_DARK_ON, - ].toSet(); - - static AndroidForceDark? fromValue(int? value) { - if (value != null) { - try { - return AndroidForceDark.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "FORCE_DARK_AUTO"; - case 2: - return "FORCE_DARK_ON"; - case 0: - default: - return "FORCE_DARK_OFF"; - } - } - - ///Disable force dark, irrespective of the force dark mode of the WebView parent. - ///In this mode, WebView content will always be rendered as-is, regardless of whether native views are being automatically darkened. - static const FORCE_DARK_OFF = const AndroidForceDark._internal(0); - - ///Enable force dark dependent on the state of the WebView parent view. - static const FORCE_DARK_AUTO = const AndroidForceDark._internal(1); - - ///Unconditionally enable force dark. In this mode WebView content will always be rendered so as to emulate a dark theme. - static const FORCE_DARK_ON = const AndroidForceDark._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class used to set the underlying layout algorithm. -class LayoutAlgorithm { - final String _value; - - const LayoutAlgorithm._internal(this._value); - - static final Set values = [ - LayoutAlgorithm.NORMAL, - LayoutAlgorithm.TEXT_AUTOSIZING, - LayoutAlgorithm.NARROW_COLUMNS, - ].toSet(); - - static LayoutAlgorithm? fromValue(String? value) { - if (value != null) { - try { - return LayoutAlgorithm.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - String toValue() => _value; - - @override - String toString() => _value; - - ///NORMAL means no rendering changes. This is the recommended choice for maximum compatibility across different platforms and Android versions. - static const NORMAL = const LayoutAlgorithm._internal("NORMAL"); - - ///TEXT_AUTOSIZING boosts font size of paragraphs based on heuristics to make the text readable when viewing a wide-viewport layout in the overview mode. - ///It is recommended to enable zoom support [AndroidInAppWebViewOptions.supportZoom] when using this mode. - /// - ///**NOTE**: available on Android 19+. - static const TEXT_AUTOSIZING = - const LayoutAlgorithm._internal("TEXT_AUTOSIZING"); - - ///NARROW_COLUMNS makes all columns no wider than the screen if possible. Only use this for API levels prior to `Build.VERSION_CODES.KITKAT`. - static const NARROW_COLUMNS = - const LayoutAlgorithm._internal("NARROW_COLUMNS"); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///An Android-specific class used to set the underlying layout algorithm. -///Use [LayoutAlgorithm] instead. -@Deprecated("Use LayoutAlgorithm instead") -class AndroidLayoutAlgorithm { - final String _value; - - const AndroidLayoutAlgorithm._internal(this._value); - - static final Set values = [ - AndroidLayoutAlgorithm.NORMAL, - AndroidLayoutAlgorithm.TEXT_AUTOSIZING, - AndroidLayoutAlgorithm.NARROW_COLUMNS, - ].toSet(); - - static AndroidLayoutAlgorithm? fromValue(String? value) { - if (value != null) { - try { - return AndroidLayoutAlgorithm.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - String toValue() => _value; - - @override - String toString() => _value; - - ///NORMAL means no rendering changes. This is the recommended choice for maximum compatibility across different platforms and Android versions. - static const NORMAL = const AndroidLayoutAlgorithm._internal("NORMAL"); - - ///TEXT_AUTOSIZING boosts font size of paragraphs based on heuristics to make the text readable when viewing a wide-viewport layout in the overview mode. - ///It is recommended to enable zoom support [AndroidInAppWebViewOptions.supportZoom] when using this mode. - /// - ///**NOTE**: available on Android 19+. - static const TEXT_AUTOSIZING = - const AndroidLayoutAlgorithm._internal("TEXT_AUTOSIZING"); - - ///NARROW_COLUMNS makes all columns no wider than the screen if possible. Only use this for API levels prior to `Build.VERSION_CODES.KITKAT`. - static const NARROW_COLUMNS = - const AndroidLayoutAlgorithm._internal("NARROW_COLUMNS"); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class used to configure the WebView's behavior when a secure origin attempts to load a resource from an insecure origin. -/// -///**NOTE**: available on Android 21+. -class MixedContentMode { - final int _value; - - const MixedContentMode._internal(this._value); - - static final Set values = [ - MixedContentMode.MIXED_CONTENT_ALWAYS_ALLOW, - MixedContentMode.MIXED_CONTENT_NEVER_ALLOW, - MixedContentMode.MIXED_CONTENT_COMPATIBILITY_MODE, - ].toSet(); - - static MixedContentMode? fromValue(int? value) { - if (value != null) { - try { - return MixedContentMode.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "MIXED_CONTENT_NEVER_ALLOW"; - case 2: - return "MIXED_CONTENT_COMPATIBILITY_MODE"; - case 0: - default: - return "MIXED_CONTENT_ALWAYS_ALLOW"; - } - } - - ///In this mode, the WebView will allow a secure origin to load content from any other origin, even if that origin is insecure. - ///This is the least secure mode of operation for the WebView, and where possible apps should not set this mode. - static const MIXED_CONTENT_ALWAYS_ALLOW = const MixedContentMode._internal(0); - - ///In this mode, the WebView will not allow a secure origin to load content from an insecure origin. - ///This is the preferred and most secure mode of operation for the WebView and apps are strongly advised to use this mode. - static const MIXED_CONTENT_NEVER_ALLOW = const MixedContentMode._internal(1); - - ///In this mode, the WebView will attempt to be compatible with the approach of a modern web browser with regard to mixed content. - ///Some insecure content may be allowed to be loaded by a secure origin and other types of content will be blocked. - ///The types of content are allowed or blocked may change release to release and are not explicitly defined. - ///This mode is intended to be used by apps that are not in control of the content that they render but desire to operate in a reasonably secure environment. - ///For highest security, apps are recommended to use [MixedContentMode.MIXED_CONTENT_NEVER_ALLOW]. - static const MIXED_CONTENT_COMPATIBILITY_MODE = - const MixedContentMode._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///An Android-specific class used to configure the WebView's behavior when a secure origin attempts to load a resource from an insecure origin. -/// -///**NOTE**: available on Android 21+. -/// -///Use [MixedContentMode] instead. -@Deprecated("Use MixedContentMode instead") -class AndroidMixedContentMode { - final int _value; - - const AndroidMixedContentMode._internal(this._value); - - static final Set values = [ - AndroidMixedContentMode.MIXED_CONTENT_ALWAYS_ALLOW, - AndroidMixedContentMode.MIXED_CONTENT_NEVER_ALLOW, - AndroidMixedContentMode.MIXED_CONTENT_COMPATIBILITY_MODE, - ].toSet(); - - static AndroidMixedContentMode? fromValue(int? value) { - if (value != null) { - try { - return AndroidMixedContentMode.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "MIXED_CONTENT_NEVER_ALLOW"; - case 2: - return "MIXED_CONTENT_COMPATIBILITY_MODE"; - case 0: - default: - return "MIXED_CONTENT_ALWAYS_ALLOW"; - } - } - - ///In this mode, the WebView will allow a secure origin to load content from any other origin, even if that origin is insecure. - ///This is the least secure mode of operation for the WebView, and where possible apps should not set this mode. - static const MIXED_CONTENT_ALWAYS_ALLOW = - const AndroidMixedContentMode._internal(0); - - ///In this mode, the WebView will not allow a secure origin to load content from an insecure origin. - ///This is the preferred and most secure mode of operation for the WebView and apps are strongly advised to use this mode. - static const MIXED_CONTENT_NEVER_ALLOW = - const AndroidMixedContentMode._internal(1); - - ///In this mode, the WebView will attempt to be compatible with the approach of a modern web browser with regard to mixed content. - ///Some insecure content may be allowed to be loaded by a secure origin and other types of content will be blocked. - ///The types of content are allowed or blocked may change release to release and are not explicitly defined. - ///This mode is intended to be used by apps that are not in control of the content that they render but desire to operate in a reasonably secure environment. - ///For highest security, apps are recommended to use [AndroidMixedContentMode.MIXED_CONTENT_NEVER_ALLOW]. - static const MIXED_CONTENT_COMPATIBILITY_MODE = - const AndroidMixedContentMode._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class used to set the level of granularity with which the user can interactively select content in the web view. -class SelectionGranularity { - final int _value; - - const SelectionGranularity._internal(this._value); - - static final Set values = [ - SelectionGranularity.DYNAMIC, - SelectionGranularity.CHARACTER, - ].toSet(); - - static SelectionGranularity? fromValue(int? value) { - if (value != null) { - try { - return SelectionGranularity.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "CHARACTER"; - case 0: - default: - return "DYNAMIC"; - } - } - - ///Selection granularity varies automatically based on the selection. - static const DYNAMIC = const SelectionGranularity._internal(0); - - ///Selection endpoints can be placed at any character boundary. - static const CHARACTER = const SelectionGranularity._internal(1); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///An iOS-specific class used to set the level of granularity with which the user can interactively select content in the web view. -///Use [SelectionGranularity] instead. -@Deprecated("Use SelectionGranularity instead") -class IOSWKSelectionGranularity { - final int _value; - - const IOSWKSelectionGranularity._internal(this._value); - - static final Set values = [ - IOSWKSelectionGranularity.DYNAMIC, - IOSWKSelectionGranularity.CHARACTER, - ].toSet(); - - static IOSWKSelectionGranularity? fromValue(int? value) { - if (value != null) { - try { - return IOSWKSelectionGranularity.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "CHARACTER"; - case 0: - default: - return "DYNAMIC"; - } - } - - ///Selection granularity varies automatically based on the selection. - static const DYNAMIC = const IOSWKSelectionGranularity._internal(0); - - ///Selection endpoints can be placed at any character boundary. - static const CHARACTER = const IOSWKSelectionGranularity._internal(1); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class used to specify a `dataDetectoryTypes` value that adds interactivity to web content that matches the value. -/// -///**NOTE**: available on iOS 10.0+. -class DataDetectorTypes { - final String _value; - - const DataDetectorTypes._internal(this._value); - - static final Set values = [ - DataDetectorTypes.NONE, - DataDetectorTypes.PHONE_NUMBER, - DataDetectorTypes.LINK, - DataDetectorTypes.ADDRESS, - DataDetectorTypes.CALENDAR_EVENT, - DataDetectorTypes.TRACKING_NUMBER, - DataDetectorTypes.FLIGHT_NUMBER, - DataDetectorTypes.LOOKUP_SUGGESTION, - DataDetectorTypes.SPOTLIGHT_SUGGESTION, - DataDetectorTypes.ALL, - ].toSet(); - - static DataDetectorTypes? fromValue(String? value) { - if (value != null) { - try { - return DataDetectorTypes.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - String toValue() => _value; - - @override - String toString() => _value; - - ///No detection is performed. - static const NONE = const DataDetectorTypes._internal("NONE"); - - ///Phone numbers are detected and turned into links. - static const PHONE_NUMBER = const DataDetectorTypes._internal("PHONE_NUMBER"); - - ///URLs in text are detected and turned into links. - static const LINK = const DataDetectorTypes._internal("LINK"); - - ///Addresses are detected and turned into links. - static const ADDRESS = const DataDetectorTypes._internal("ADDRESS"); - - ///Dates and times that are in the future are detected and turned into links. - static const CALENDAR_EVENT = - const DataDetectorTypes._internal("CALENDAR_EVENT"); - - ///Tracking numbers are detected and turned into links. - static const TRACKING_NUMBER = - const DataDetectorTypes._internal("TRACKING_NUMBER"); - - ///Flight numbers are detected and turned into links. - static const FLIGHT_NUMBER = - const DataDetectorTypes._internal("FLIGHT_NUMBER"); - - ///Lookup suggestions are detected and turned into links. - static const LOOKUP_SUGGESTION = - const DataDetectorTypes._internal("LOOKUP_SUGGESTION"); - - ///Spotlight suggestions are detected and turned into links. - static const SPOTLIGHT_SUGGESTION = - const DataDetectorTypes._internal("SPOTLIGHT_SUGGESTION"); - - ///All of the above data types are turned into links when detected. Choosing this value will automatically include any new detection type that is added. - static const ALL = const DataDetectorTypes._internal("ALL"); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///An iOS-specific class used to specify a `dataDetectoryTypes` value that adds interactivity to web content that matches the value. -/// -///**NOTE**: available on iOS 10.0+. -/// -///Use [DataDetectorTypes] instead. -@Deprecated("Use DataDetectorTypes instead") -class IOSWKDataDetectorTypes { - final String _value; - - const IOSWKDataDetectorTypes._internal(this._value); - - static final Set values = [ - IOSWKDataDetectorTypes.NONE, - IOSWKDataDetectorTypes.PHONE_NUMBER, - IOSWKDataDetectorTypes.LINK, - IOSWKDataDetectorTypes.ADDRESS, - IOSWKDataDetectorTypes.CALENDAR_EVENT, - IOSWKDataDetectorTypes.TRACKING_NUMBER, - IOSWKDataDetectorTypes.FLIGHT_NUMBER, - IOSWKDataDetectorTypes.LOOKUP_SUGGESTION, - IOSWKDataDetectorTypes.SPOTLIGHT_SUGGESTION, - IOSWKDataDetectorTypes.ALL, - ].toSet(); - - static IOSWKDataDetectorTypes? fromValue(String? value) { - if (value != null) { - try { - return IOSWKDataDetectorTypes.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - String toValue() => _value; - - @override - String toString() => _value; - - ///No detection is performed. - static const NONE = const IOSWKDataDetectorTypes._internal("NONE"); - - ///Phone numbers are detected and turned into links. - static const PHONE_NUMBER = - const IOSWKDataDetectorTypes._internal("PHONE_NUMBER"); - - ///URLs in text are detected and turned into links. - static const LINK = const IOSWKDataDetectorTypes._internal("LINK"); - - ///Addresses are detected and turned into links. - static const ADDRESS = const IOSWKDataDetectorTypes._internal("ADDRESS"); - - ///Dates and times that are in the future are detected and turned into links. - static const CALENDAR_EVENT = - const IOSWKDataDetectorTypes._internal("CALENDAR_EVENT"); - - ///Tracking numbers are detected and turned into links. - static const TRACKING_NUMBER = - const IOSWKDataDetectorTypes._internal("TRACKING_NUMBER"); - - ///Flight numbers are detected and turned into links. - static const FLIGHT_NUMBER = - const IOSWKDataDetectorTypes._internal("FLIGHT_NUMBER"); - - ///Lookup suggestions are detected and turned into links. - static const LOOKUP_SUGGESTION = - const IOSWKDataDetectorTypes._internal("LOOKUP_SUGGESTION"); - - ///Spotlight suggestions are detected and turned into links. - static const SPOTLIGHT_SUGGESTION = - const IOSWKDataDetectorTypes._internal("SPOTLIGHT_SUGGESTION"); - - ///All of the above data types are turned into links when detected. Choosing this value will automatically include any new detection type that is added. - static const ALL = const IOSWKDataDetectorTypes._internal("ALL"); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents a floating-point value that determines the rate of deceleration after the user lifts their finger. -class ScrollViewDecelerationRate { - final String _value; - - const ScrollViewDecelerationRate._internal(this._value); - - static final Set values = [ - ScrollViewDecelerationRate.NORMAL, - ScrollViewDecelerationRate.FAST, - ].toSet(); - - static ScrollViewDecelerationRate? fromValue(String? value) { - if (value != null) { - try { - return ScrollViewDecelerationRate.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - String toValue() => _value; - - @override - String toString() => _value; - - ///The default deceleration rate for a scroll view: `0.998`. - static const NORMAL = const ScrollViewDecelerationRate._internal("NORMAL"); - - ///A fast deceleration rate for a scroll view: `0.99`. - static const FAST = const ScrollViewDecelerationRate._internal("FAST"); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents a floating-point value that determines the rate of deceleration after the user lifts their finger. -///Use [ScrollViewDecelerationRate] instead. -@Deprecated("Use ScrollViewDecelerationRate instead") -class IOSUIScrollViewDecelerationRate { - final String _value; - - const IOSUIScrollViewDecelerationRate._internal(this._value); - - static final Set values = [ - IOSUIScrollViewDecelerationRate.NORMAL, - IOSUIScrollViewDecelerationRate.FAST, - ].toSet(); - - static IOSUIScrollViewDecelerationRate? fromValue(String? value) { - if (value != null) { - try { - return IOSUIScrollViewDecelerationRate.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - String toValue() => _value; - - @override - String toString() => _value; - - ///The default deceleration rate for a scroll view: `0.998`. - static const NORMAL = - const IOSUIScrollViewDecelerationRate._internal("NORMAL"); - - ///A fast deceleration rate for a scroll view: `0.99`. - static const FAST = const IOSUIScrollViewDecelerationRate._internal("FAST"); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents the content mode to prefer when loading and rendering a webpage. -class UserPreferredContentMode { - final int _value; - - const UserPreferredContentMode._internal(this._value); - - static final Set values = [ - UserPreferredContentMode.RECOMMENDED, - UserPreferredContentMode.MOBILE, - UserPreferredContentMode.DESKTOP, - ].toSet(); - - static UserPreferredContentMode? fromValue(int? value) { - if (value != null) { - try { - return UserPreferredContentMode.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "MOBILE"; - case 2: - return "DESKTOP"; - case 0: - default: - return "RECOMMENDED"; - } - } - - ///The recommended content mode for the current platform. - static const RECOMMENDED = const UserPreferredContentMode._internal(0); - - ///Represents content targeting mobile browsers. - static const MOBILE = const UserPreferredContentMode._internal(1); - - ///Represents content targeting desktop browsers. - static const DESKTOP = const UserPreferredContentMode._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class used to specify the modal presentation style when presenting a view controller. -class ModalPresentationStyle { - final int _value; - - const ModalPresentationStyle._internal(this._value); - - static final Set values = [ - ModalPresentationStyle.FULL_SCREEN, - ModalPresentationStyle.PAGE_SHEET, - ModalPresentationStyle.FORM_SHEET, - ModalPresentationStyle.CURRENT_CONTEXT, - ModalPresentationStyle.CUSTOM, - ModalPresentationStyle.OVER_FULL_SCREEN, - ModalPresentationStyle.OVER_CURRENT_CONTEXT, - ModalPresentationStyle.POPOVER, - ModalPresentationStyle.NONE, - ModalPresentationStyle.AUTOMATIC, - ].toSet(); - - static ModalPresentationStyle? fromValue(int? value) { - if (value != null) { - try { - return ModalPresentationStyle.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "PAGE_SHEET"; - case 2: - return "FORM_SHEET"; - case 3: - return "CURRENT_CONTEXT"; - case 4: - return "CUSTOM"; - case 5: - return "OVER_FULL_SCREEN"; - case 6: - return "OVER_CURRENT_CONTEXT"; - case 7: - return "POPOVER"; - case 8: - return "NONE"; - case 9: - return "AUTOMATIC"; - case 0: - default: - return "FULL_SCREEN"; - } - } - - ///A presentation style in which the presented view covers the screen. - static const FULL_SCREEN = const ModalPresentationStyle._internal(0); - - ///A presentation style that partially covers the underlying content. - static const PAGE_SHEET = const ModalPresentationStyle._internal(1); - - ///A presentation style that displays the content centered in the screen. - static const FORM_SHEET = const ModalPresentationStyle._internal(2); - - ///A presentation style where the content is displayed over another view controller’s content. - static const CURRENT_CONTEXT = const ModalPresentationStyle._internal(3); - - ///A custom view presentation style that is managed by a custom presentation controller and one or more custom animator objects. - static const CUSTOM = const ModalPresentationStyle._internal(4); - - ///A view presentation style in which the presented view covers the screen. - static const OVER_FULL_SCREEN = const ModalPresentationStyle._internal(5); - - ///A presentation style where the content is displayed over another view controller’s content. - static const OVER_CURRENT_CONTEXT = const ModalPresentationStyle._internal(6); - - ///A presentation style where the content is displayed in a popover view. - static const POPOVER = const ModalPresentationStyle._internal(7); - - ///A presentation style that indicates no adaptations should be made. - static const NONE = const ModalPresentationStyle._internal(8); - - ///The default presentation style chosen by the system. - /// - ///**NOTE**: available on iOS 13.0+. - static const AUTOMATIC = const ModalPresentationStyle._internal(9); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///An iOS-specific class used to specify the modal presentation style when presenting a view controller. -///Use [ModalPresentationStyle] instead. -@Deprecated("Use ModalPresentationStyle instead") -class IOSUIModalPresentationStyle { - final int _value; - - const IOSUIModalPresentationStyle._internal(this._value); - - static final Set values = [ - IOSUIModalPresentationStyle.FULL_SCREEN, - IOSUIModalPresentationStyle.PAGE_SHEET, - IOSUIModalPresentationStyle.FORM_SHEET, - IOSUIModalPresentationStyle.CURRENT_CONTEXT, - IOSUIModalPresentationStyle.CUSTOM, - IOSUIModalPresentationStyle.OVER_FULL_SCREEN, - IOSUIModalPresentationStyle.OVER_CURRENT_CONTEXT, - IOSUIModalPresentationStyle.POPOVER, - IOSUIModalPresentationStyle.NONE, - IOSUIModalPresentationStyle.AUTOMATIC, - ].toSet(); - - static IOSUIModalPresentationStyle? fromValue(int? value) { - if (value != null) { - try { - return IOSUIModalPresentationStyle.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "PAGE_SHEET"; - case 2: - return "FORM_SHEET"; - case 3: - return "CURRENT_CONTEXT"; - case 4: - return "CUSTOM"; - case 5: - return "OVER_FULL_SCREEN"; - case 6: - return "OVER_CURRENT_CONTEXT"; - case 7: - return "POPOVER"; - case 8: - return "NONE"; - case 9: - return "AUTOMATIC"; - case 0: - default: - return "FULL_SCREEN"; - } - } - - ///A presentation style in which the presented view covers the screen. - static const FULL_SCREEN = const IOSUIModalPresentationStyle._internal(0); - - ///A presentation style that partially covers the underlying content. - static const PAGE_SHEET = const IOSUIModalPresentationStyle._internal(1); - - ///A presentation style that displays the content centered in the screen. - static const FORM_SHEET = const IOSUIModalPresentationStyle._internal(2); - - ///A presentation style where the content is displayed over another view controller’s content. - static const CURRENT_CONTEXT = const IOSUIModalPresentationStyle._internal(3); - - ///A custom view presentation style that is managed by a custom presentation controller and one or more custom animator objects. - static const CUSTOM = const IOSUIModalPresentationStyle._internal(4); - - ///A view presentation style in which the presented view covers the screen. - static const OVER_FULL_SCREEN = - const IOSUIModalPresentationStyle._internal(5); - - ///A presentation style where the content is displayed over another view controller’s content. - static const OVER_CURRENT_CONTEXT = - const IOSUIModalPresentationStyle._internal(6); - - ///A presentation style where the content is displayed in a popover view. - static const POPOVER = const IOSUIModalPresentationStyle._internal(7); - - ///A presentation style that indicates no adaptations should be made. - static const NONE = const IOSUIModalPresentationStyle._internal(8); - - ///The default presentation style chosen by the system. - /// - ///**NOTE**: available on iOS 13.0+. - static const AUTOMATIC = const IOSUIModalPresentationStyle._internal(9); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class used to specify the transition style when presenting a view controller. -class ModalTransitionStyle { - final int _value; - - const ModalTransitionStyle._internal(this._value); - - static final Set values = [ - ModalTransitionStyle.COVER_VERTICAL, - ModalTransitionStyle.FLIP_HORIZONTAL, - ModalTransitionStyle.CROSS_DISSOLVE, - ModalTransitionStyle.PARTIAL_CURL, - ].toSet(); - - static ModalTransitionStyle? fromValue(int? value) { - if (value != null) { - try { - return ModalTransitionStyle.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "FLIP_HORIZONTAL"; - case 2: - return "CROSS_DISSOLVE"; - case 3: - return "PARTIAL_CURL"; - case 0: - default: - return "COVER_VERTICAL"; - } - } - - ///When the view controller is presented, its view slides up from the bottom of the screen. - ///On dismissal, the view slides back down. This is the default transition style. - static const COVER_VERTICAL = const ModalTransitionStyle._internal(0); - - ///When the view controller is presented, the current view initiates a horizontal 3D flip from right-to-left, - ///resulting in the revealing of the new view as if it were on the back of the previous view. - ///On dismissal, the flip occurs from left-to-right, returning to the original view. - static const FLIP_HORIZONTAL = const ModalTransitionStyle._internal(1); - - ///When the view controller is presented, the current view fades out while the new view fades in at the same time. - ///On dismissal, a similar type of cross-fade is used to return to the original view. - static const CROSS_DISSOLVE = const ModalTransitionStyle._internal(2); - - ///When the view controller is presented, one corner of the current view curls up to reveal the presented view underneath. - ///On dismissal, the curled up page unfurls itself back on top of the presented view. - ///A view controller presented using this transition is itself prevented from presenting any additional view controllers. - static const PARTIAL_CURL = const ModalTransitionStyle._internal(3); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///An iOS-specific class used to specify the transition style when presenting a view controller. -///Use [ModalTransitionStyle] instead. -@Deprecated("Use ModalTransitionStyle instead") -class IOSUIModalTransitionStyle { - final int _value; - - const IOSUIModalTransitionStyle._internal(this._value); - - static final Set values = [ - IOSUIModalTransitionStyle.COVER_VERTICAL, - IOSUIModalTransitionStyle.FLIP_HORIZONTAL, - IOSUIModalTransitionStyle.CROSS_DISSOLVE, - IOSUIModalTransitionStyle.PARTIAL_CURL, - ].toSet(); - - static IOSUIModalTransitionStyle? fromValue(int? value) { - if (value != null) { - try { - return IOSUIModalTransitionStyle.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "FLIP_HORIZONTAL"; - case 2: - return "CROSS_DISSOLVE"; - case 3: - return "PARTIAL_CURL"; - case 0: - default: - return "COVER_VERTICAL"; - } - } - - ///When the view controller is presented, its view slides up from the bottom of the screen. - ///On dismissal, the view slides back down. This is the default transition style. - static const COVER_VERTICAL = const IOSUIModalTransitionStyle._internal(0); - - ///When the view controller is presented, the current view initiates a horizontal 3D flip from right-to-left, - ///resulting in the revealing of the new view as if it were on the back of the previous view. - ///On dismissal, the flip occurs from left-to-right, returning to the original view. - static const FLIP_HORIZONTAL = const IOSUIModalTransitionStyle._internal(1); - - ///When the view controller is presented, the current view fades out while the new view fades in at the same time. - ///On dismissal, a similar type of cross-fade is used to return to the original view. - static const CROSS_DISSOLVE = const IOSUIModalTransitionStyle._internal(2); - - ///When the view controller is presented, one corner of the current view curls up to reveal the presented view underneath. - ///On dismissal, the curled up page unfurls itself back on top of the presented view. - ///A view controller presented using this transition is itself prevented from presenting any additional view controllers. - static const PARTIAL_CURL = const IOSUIModalTransitionStyle._internal(3); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class used to set the custom style for the dismiss button. -/// -///**NOTE**: available on iOS 11.0+. -class DismissButtonStyle { - final int _value; - - const DismissButtonStyle._internal(this._value); - - static final Set values = [ - DismissButtonStyle.DONE, - DismissButtonStyle.CLOSE, - DismissButtonStyle.CANCEL, - ].toSet(); - - static DismissButtonStyle? fromValue(int? value) { - if (value != null) { - try { - return DismissButtonStyle.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "CLOSE"; - case 2: - return "CANCEL"; - case 0: - default: - return "DONE"; - } - } - - ///Makes the button title the localized string "Done". - static const DONE = const DismissButtonStyle._internal(0); - - ///Makes the button title the localized string "Close". - static const CLOSE = const DismissButtonStyle._internal(1); - - ///Makes the button title the localized string "Cancel". - static const CANCEL = const DismissButtonStyle._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///An iOS-specific class used to set the custom style for the dismiss button. -/// -///**NOTE**: available on iOS 11.0+. -/// -///Use [DismissButtonStyle] instead. -@Deprecated("Use DismissButtonStyle instead") -class IOSSafariDismissButtonStyle { - final int _value; - - const IOSSafariDismissButtonStyle._internal(this._value); - - static final Set values = [ - IOSSafariDismissButtonStyle.DONE, - IOSSafariDismissButtonStyle.CLOSE, - IOSSafariDismissButtonStyle.CANCEL, - ].toSet(); - - static IOSSafariDismissButtonStyle? fromValue(int? value) { - if (value != null) { - try { - return IOSSafariDismissButtonStyle.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "CLOSE"; - case 2: - return "CANCEL"; - case 0: - default: - return "DONE"; - } - } - - ///Makes the button title the localized string "Done". - static const DONE = const IOSSafariDismissButtonStyle._internal(0); - - ///Makes the button title the localized string "Close". - static const CLOSE = const IOSSafariDismissButtonStyle._internal(1); - - ///Makes the button title the localized string "Cancel". - static const CANCEL = const IOSSafariDismissButtonStyle._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class used by [AjaxRequest] class. -class AjaxRequestAction { - final int _value; - - const AjaxRequestAction._internal(this._value); - - int toValue() => _value; - - ///Aborts the current [AjaxRequest]. - static const ABORT = const AjaxRequestAction._internal(0); - - ///Proceeds with the current [AjaxRequest]. - static const PROCEED = const AjaxRequestAction._internal(1); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; - - Map toMap() { - return { - "action": _value, - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class used by [AjaxRequestEvent] class. -class AjaxRequestEventType { - final String _value; - - const AjaxRequestEventType._internal(this._value); - - static final Set values = [ - AjaxRequestEventType.LOADSTART, - AjaxRequestEventType.LOAD, - AjaxRequestEventType.LOADEND, - AjaxRequestEventType.PROGRESS, - AjaxRequestEventType.ERROR, - AjaxRequestEventType.ABORT, - AjaxRequestEventType.TIMEOUT, - ].toSet(); - - static AjaxRequestEventType? fromValue(String? value) { - if (value != null) { - try { - return AjaxRequestEventType.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - String toValue() => _value; - - String toString() => _value; - - ///The LOADSTART event is fired when a request has started to load data. - static const LOADSTART = const AjaxRequestEventType._internal("loadstart"); - - ///The LOAD event is fired when an `XMLHttpRequest` transaction completes successfully. - static const LOAD = const AjaxRequestEventType._internal("load"); - - ///The LOADEND event is fired when a request has completed, whether successfully (after [AjaxRequestEventType.LOAD]) or - ///unsuccessfully (after [AjaxRequestEventType.ABORT] or [AjaxRequestEventType.ERROR]). - static const LOADEND = const AjaxRequestEventType._internal("loadend"); - - ///The PROGRESS event is fired periodically when a request receives more data. - static const PROGRESS = const AjaxRequestEventType._internal("progress"); - - ///The ERROR event is fired when the request encountered an error. - static const ERROR = const AjaxRequestEventType._internal("error"); - - ///The ABORT event is fired when a request has been aborted. - static const ABORT = const AjaxRequestEventType._internal("abort"); - - ///The TIMEOUT event is fired when progression is terminated due to preset time expiring. - static const TIMEOUT = const AjaxRequestEventType._internal("timeout"); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class used by [AjaxRequest] class. It represents events measuring progress of an [AjaxRequest]. -class AjaxRequestEvent { - ///Event type. - AjaxRequestEventType? type; - - ///Is a Boolean flag indicating if the total work to be done, and the amount of work already done, by the underlying process is calculable. - ///In other words, it tells if the progress is measurable or not. - bool? lengthComputable; - - ///Is an integer representing the amount of work already performed by the underlying process. - ///The ratio of work done can be calculated with the property and [AjaxRequestEvent.total]. - ///When downloading a resource using HTTP, this only represent the part of the content itself, not headers and other overhead. - int? loaded; - - ///Is an integer representing the total amount of work that the underlying process is in the progress of performing. - ///When downloading a resource using HTTP, this only represent the content itself, not headers and other overhead. - int? total; - - AjaxRequestEvent({this.type, this.lengthComputable, this.loaded, this.total}); - - static AjaxRequestEvent? fromMap(Map? map) { - if (map == null) { - return null; - } - - return AjaxRequestEvent( - type: AjaxRequestEventType.fromValue(map["type"]), - lengthComputable: map["lengthComputable"], - loaded: map["loaded"], - total: map["total"]); - } - - Map toMap() { - return { - "type": type?.toValue(), - "lengthComputable": lengthComputable, - "loaded": loaded, - "total": total, - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class used by [AjaxRequest] class. It represents the state of an [AjaxRequest]. -class AjaxRequestReadyState { - final int _value; - - const AjaxRequestReadyState._internal(this._value); - - static final Set values = [ - AjaxRequestReadyState.UNSENT, - AjaxRequestReadyState.OPENED, - AjaxRequestReadyState.HEADERS_RECEIVED, - AjaxRequestReadyState.LOADING, - AjaxRequestReadyState.DONE, - ].toSet(); - - static AjaxRequestReadyState? fromValue(int? value) { - if (value != null) { - try { - return AjaxRequestReadyState.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "OPENED"; - case 2: - return "HEADERS_RECEIVED"; - case 3: - return "LOADING"; - case 4: - return "DONE"; - case 0: - default: - return "UNSENT"; - } - } - - ///Client has been created. `XMLHttpRequest.open()` not called yet. - static const UNSENT = const AjaxRequestReadyState._internal(0); - - ///`XMLHttpRequest.open()` has been called. - static const OPENED = const AjaxRequestReadyState._internal(1); - - ///`XMLHttpRequest.send()` has been called, and [AjaxRequest.headers] and [AjaxRequest.status] are available. - static const HEADERS_RECEIVED = const AjaxRequestReadyState._internal(2); - - ///Downloading; [AjaxRequest.responseText] holds partial data. - static const LOADING = const AjaxRequestReadyState._internal(3); - - ///The operation is complete. - static const DONE = const AjaxRequestReadyState._internal(4); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents the HTTP headers of an [AjaxRequest]. -class AjaxRequestHeaders { - Map _headers; - Map _newHeaders = {}; - - AjaxRequestHeaders(this._headers); - - static AjaxRequestHeaders? fromMap(Map? map) { - if (map == null) { - return null; - } - - return AjaxRequestHeaders(map); - } - - ///Gets the HTTP headers of the [AjaxRequest]. - Map getHeaders() { - return this._headers; - } - - ///Sets/updates an HTTP header of the [AjaxRequest]. If there is already an existing [header] with the same name, the values are merged into one single request header. - ///For security reasons, some headers can only be controlled by the user agent. - ///These headers include the [forbidden header names](https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name) - ///and [forbidden response header names](https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_response_header_name). - void setRequestHeader(String header, String value) { - _newHeaders[header] = value; - } - - Map toMap() { - return _newHeaders; - } - - Map toJson() { - return toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents a JavaScript [XMLHttpRequest](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) object. -class AjaxRequest { - ///Data passed as a parameter to the `XMLHttpRequest.send()` method. - dynamic data; - - ///The HTTP request method of the `XMLHttpRequest` request. - String? method; - - ///The URL of the `XMLHttpRequest` request. - Uri? url; - - ///An optional Boolean parameter, defaulting to true, indicating whether or not the request is performed asynchronously. - bool? isAsync; - - ///The optional user name to use for authentication purposes; by default, this is the null value. - String? user; - - ///The optional password to use for authentication purposes; by default, this is the null value. - String? password; - - ///The XMLHttpRequest.withCredentials property is a Boolean that indicates whether or not cross-site Access-Control requests - ///should be made using credentials such as cookies, authorization headers or TLS client certificates. - ///Setting withCredentials has no effect on same-site requests. - ///In addition, this flag is also used to indicate when cookies are to be ignored in the response. The default is false. - bool? withCredentials; - - ///The HTTP request headers. - AjaxRequestHeaders? headers; - - ///The state of the `XMLHttpRequest` request. - AjaxRequestReadyState? readyState; - - ///The numerical HTTP [status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status) of the `XMLHttpRequest`'s response. - int? status; - - ///The serialized URL of the response or the empty string if the URL is null. - ///If the URL is returned, any URL fragment present in the URL will be stripped away. - ///The value of responseURL will be the final URL obtained after any redirects. - Uri? responseURL; - - ///It is an enumerated string value specifying the type of data contained in the response. - ///It also lets the author change the [response type](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseType). - ///If an empty string is set as the value of responseType, the default value of text is used. - String? responseType; - - ///The response's body content. The content-type depends on the [AjaxRequest.reponseType]. - dynamic response; - - ///The text received from a server following a request being sent. - String? responseText; - - ///The HTML or XML string retrieved by the request or null if the request was unsuccessful, has not yet been sent, or if the data can't be parsed as XML or HTML. - String? responseXML; - - ///A String containing the response's status message as returned by the HTTP server. - ///Unlike [AjaxRequest.status] which indicates a numerical status code, this property contains the text of the response status, such as "OK" or "Not Found". - ///If the request's readyState is in [AjaxRequestReadyState.UNSENT] or [AjaxRequestReadyState.OPENED] state, the value of statusText will be an empty string. - ///If the server response doesn't explicitly specify a status text, statusText will assume the default value "OK". - String? statusText; - - ///All the response headers or returns null if no response has been received. If a network error happened, an empty string is returned. - Map? responseHeaders; - - ///Event type of the `XMLHttpRequest` request. - AjaxRequestEvent? event; - - ///Indicates the [AjaxRequestAction] that can be used to control the `XMLHttpRequest` request. - AjaxRequestAction? action; - - AjaxRequest( - {this.data, - this.method, - this.url, - this.isAsync, - this.user, - this.password, - this.withCredentials, - this.headers, - this.readyState, - this.status, - this.responseURL, - this.responseType, - this.response, - this.responseText, - this.responseXML, - this.statusText, - this.responseHeaders, - this.event, - this.action = AjaxRequestAction.PROCEED}); - - static AjaxRequest? fromMap(Map? map) { - if (map == null) { - return null; - } - - return AjaxRequest( - data: map["data"], - method: map["method"], - url: map["url"] != null ? Uri.parse(map["url"]) : null, - isAsync: map["isAsync"], - user: map["user"], - password: map["password"], - withCredentials: map["withCredentials"], - headers: - AjaxRequestHeaders.fromMap(map["headers"]?.cast()), - readyState: AjaxRequestReadyState.fromValue(map["readyState"]), - status: map["status"], - responseURL: - map["responseURL"] != null ? Uri.parse(map["responseURL"]) : null, - responseType: map["responseType"], - response: map["response"], - responseText: map["responseText"], - responseXML: map["responseXML"], - statusText: map["statusText"], - responseHeaders: map["responseHeaders"]?.cast(), - event: AjaxRequestEvent.fromMap(map["event"]?.cast())); - } - - Map toMap() { - return { - "data": data, - "method": method, - "url": url?.toString(), - "isAsync": isAsync, - "user": user, - "password": password, - "withCredentials": withCredentials, - "headers": headers?.toMap(), - "readyState": readyState?.toValue(), - "status": status, - "responseURL": responseURL?.toString(), - "responseType": responseType, - "response": response, - "responseText": responseText, - "responseXML": responseXML, - "statusText": statusText, - "responseHeaders": responseHeaders, - "action": action?.toValue() - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class used by [FetchRequest] class. -class FetchRequestAction { - final int _value; - - const FetchRequestAction._internal(this._value); - - int toValue() => _value; - - ///Aborts the fetch request. - static const ABORT = const FetchRequestAction._internal(0); - - ///Proceeds with the fetch request. - static const PROCEED = const FetchRequestAction._internal(1); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that is an interface for [FetchRequestCredentialDefault], [FetchRequestFederatedCredential] and [FetchRequestPasswordCredential] classes. -class FetchRequestCredential { - ///Type of credentials. - String? type; - - FetchRequestCredential({this.type}); - - Map toMap() { - return {"type": type}; - } - - static FetchRequestCredential? fromMap(Map? map) { - if (map == null) { - return null; - } - return FetchRequestCredential(type: map["type"]); - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents the default credentials used by an [FetchRequest]. -class FetchRequestCredentialDefault extends FetchRequestCredential { - ///The value of the credentials. - String? value; - - FetchRequestCredentialDefault({type, this.value}) : super(type: type); - - Map toMap() { - return { - "type": type, - "value": value, - }; - } - - static FetchRequestCredentialDefault? fromMap( - Map? credentialsMap) { - if (credentialsMap == null) { - return null; - } - return FetchRequestCredentialDefault( - type: credentialsMap["type"], value: credentialsMap["value"]); - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents a [FederatedCredential](https://developer.mozilla.org/en-US/docs/Web/API/FederatedCredential) type of credentials. -class FetchRequestFederatedCredential extends FetchRequestCredential { - ///Credential's identifier. - dynamic id; - - ///The name associated with a credential. It should be a human-readable, public name. - String? name; - - ///Credential's federated identity protocol. - String? protocol; - - ///Credential's federated identity provider. - String? provider; - - ///URL pointing to an image for an icon. This image is intended for display in a credential chooser. The URL must be accessible without authentication. - Uri? iconURL; - - FetchRequestFederatedCredential( - {type, this.id, this.name, this.protocol, this.provider, this.iconURL}) - : super(type: type); - - static FetchRequestFederatedCredential? fromMap( - Map? credentialsMap) { - if (credentialsMap == null) { - return null; - } - return FetchRequestFederatedCredential( - type: credentialsMap["type"], - id: credentialsMap["id"], - name: credentialsMap["name"], - protocol: credentialsMap["protocol"], - provider: credentialsMap["provider"], - iconURL: credentialsMap["iconURL"] != null - ? Uri.parse(credentialsMap["iconURL"]) - : null); - } - - Map toMap() { - return { - "type": type, - "id": id, - "name": name, - "protocol": protocol, - "provider": provider, - "iconURL": iconURL?.toString() - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents a [PasswordCredential](https://developer.mozilla.org/en-US/docs/Web/API/PasswordCredential) type of credentials. -class FetchRequestPasswordCredential extends FetchRequestCredential { - ///Credential's identifier. - dynamic id; - - ///The name associated with a credential. It should be a human-readable, public name. - String? name; - - ///The password of the credential. - String? password; - - ///URL pointing to an image for an icon. This image is intended for display in a credential chooser. The URL must be accessible without authentication. - Uri? iconURL; - - FetchRequestPasswordCredential( - {type, this.id, this.name, this.password, this.iconURL}) - : super(type: type); - - static FetchRequestPasswordCredential? fromMap( - Map? credentialsMap) { - if (credentialsMap == null) { - return null; - } - return FetchRequestPasswordCredential( - type: credentialsMap["type"], - id: credentialsMap["id"], - name: credentialsMap["name"], - password: credentialsMap["password"], - iconURL: credentialsMap["iconURL"] != null - ? Uri.parse(credentialsMap["iconURL"]) - : null); - } - - Map toMap() { - return { - "type": type, - "id": id, - "name": name, - "password": password, - "iconURL": iconURL?.toString() - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents a HTTP request created with JavaScript using the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch). -class FetchRequest { - ///The URL of the request. - Uri? url; - - ///The HTTP request method used of the request. - String? method; - - ///The HTTP request headers. - Map? headers; - - ///Body of the request. - dynamic body; - - ///The mode used by the request. - String? mode; - - ///The request credentials used by the request. - FetchRequestCredential? credentials; - - ///The cache mode used by the request. - String? cache; - - ///The redirect mode used by the request. - String? redirect; - - ///A String specifying no-referrer, client, or a URL. - String? referrer; - - ///The value of the referer HTTP header. - ReferrerPolicy? referrerPolicy; - - ///Contains the subresource integrity value of the request. - String? integrity; - - ///The keepalive option used to allow the request to outlive the page. - bool? keepalive; - - ///Indicates the [FetchRequestAction] that can be used to control the request. - FetchRequestAction? action; - - FetchRequest( - {this.url, - this.method, - this.headers, - this.body, - this.mode, - this.credentials, - this.cache, - this.redirect, - this.referrer, - this.referrerPolicy, - this.integrity, - this.keepalive, - this.action = FetchRequestAction.PROCEED}); - - static FetchRequest? fromMap(Map? map) { - if (map == null) { - return null; - } - - Map? credentialMap = - map["credentials"]?.cast(); - FetchRequestCredential? credentials; - if (credentialMap != null) { - if (credentialMap["type"] == "default") { - credentials = FetchRequestCredentialDefault.fromMap(credentialMap); - } else if (credentialMap["type"] == "federated") { - credentials = FetchRequestFederatedCredential.fromMap(credentialMap); - } else if (credentialMap["type"] == "password") { - credentials = FetchRequestPasswordCredential.fromMap(credentialMap); - } - } - - return FetchRequest( - url: map["url"] != null ? Uri.parse(map["url"]) : null, - method: map["method"], - headers: map["headers"]?.cast(), - body: map["body"], - mode: map["mode"], - credentials: credentials, - cache: map["cache"], - redirect: map["redirect"], - referrer: map["referrer"], - referrerPolicy: ReferrerPolicy.fromValue(map["referrerPolicy"]), - integrity: map["integrity"], - keepalive: map["keepalive"]); - } - - Map toMap() { - return { - "url": url?.toString(), - "method": method, - "headers": headers, - "body": body, - "mode": mode, - "credentials": credentials?.toMap(), - "cache": cache, - "redirect": redirect, - "referrer": referrer, - "referrerPolicy": referrerPolicy?.toValue(), - "integrity": integrity, - "keepalive": keepalive, - "action": action?.toValue() - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents the possible resource type defined for a [ContentBlockerTrigger]. -class ContentBlockerTriggerResourceType { - final String _value; - - const ContentBlockerTriggerResourceType._internal(this._value); - - static final Set values = [ - ContentBlockerTriggerResourceType.DOCUMENT, - ContentBlockerTriggerResourceType.IMAGE, - ContentBlockerTriggerResourceType.STYLE_SHEET, - ContentBlockerTriggerResourceType.SCRIPT, - ContentBlockerTriggerResourceType.FONT, - ContentBlockerTriggerResourceType.MEDIA, - ContentBlockerTriggerResourceType.SVG_DOCUMENT, - ContentBlockerTriggerResourceType.RAW, - ].toSet(); - - static ContentBlockerTriggerResourceType? fromValue(String? value) { - if (value != null) { - try { - return ContentBlockerTriggerResourceType.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - String toValue() => _value; - - @override - String toString() => _value; - - static const DOCUMENT = - const ContentBlockerTriggerResourceType._internal('document'); - static const IMAGE = - const ContentBlockerTriggerResourceType._internal('image'); - static const STYLE_SHEET = - const ContentBlockerTriggerResourceType._internal('style-sheet'); - static const SCRIPT = - const ContentBlockerTriggerResourceType._internal('script'); - static const FONT = const ContentBlockerTriggerResourceType._internal('font'); - static const MEDIA = - const ContentBlockerTriggerResourceType._internal('media'); - static const SVG_DOCUMENT = - const ContentBlockerTriggerResourceType._internal('svg-document'); - - ///Any untyped load - static const RAW = const ContentBlockerTriggerResourceType._internal('raw'); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents the possible load type for a [ContentBlockerTrigger]. -class ContentBlockerTriggerLoadType { - final String _value; - - const ContentBlockerTriggerLoadType._internal(this._value); - - static final Set values = [ - ContentBlockerTriggerLoadType.FIRST_PARTY, - ContentBlockerTriggerLoadType.THIRD_PARTY, - ].toSet(); - - static ContentBlockerTriggerLoadType? fromValue(String? value) { - if (value != null) { - try { - return ContentBlockerTriggerLoadType.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - String toValue() => _value; - - @override - String toString() => _value; - - ///FIRST_PARTY is triggered only if the resource has the same scheme, domain, and port as the main page resource. - static const FIRST_PARTY = - const ContentBlockerTriggerLoadType._internal('first-party'); - - ///THIRD_PARTY is triggered if the resource is not from the same domain as the main page resource. - static const THIRD_PARTY = - const ContentBlockerTriggerLoadType._internal('third-party'); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents the kind of action that can be used with a [ContentBlockerTrigger]. -class ContentBlockerActionType { - final String _value; - - const ContentBlockerActionType._internal(this._value); - - static final Set values = [ - ContentBlockerActionType.BLOCK, - ContentBlockerActionType.CSS_DISPLAY_NONE, - ContentBlockerActionType.MAKE_HTTPS, - ].toSet(); - - static ContentBlockerActionType? fromValue(String? value) { - if (value != null) { - try { - return ContentBlockerActionType.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - String toValue() => _value; - - @override - String toString() => _value; - - ///Stops loading of the resource. If the resource was cached, the cache is ignored. - static const BLOCK = const ContentBlockerActionType._internal('block'); - - ///Hides elements of the page based on a CSS selector. A selector field contains the selector list. Any matching element has its display property set to none, which hides it. - /// - ///**NOTE**: on Android, JavaScript must be enabled. - static const CSS_DISPLAY_NONE = - const ContentBlockerActionType._internal('css-display-none'); - - ///Changes a URL from http to https. URLs with a specified (nondefault) port and links using other protocols are unaffected. - static const MAKE_HTTPS = - const ContentBlockerActionType._internal('make-https'); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents a cookie returned by the [CookieManager]. -class Cookie { - ///The cookie name. - String name; - - ///The cookie value. - dynamic value; - - ///The cookie expiration date in milliseconds. - /// - ///**NOTE**: on Android it will be always `null`. - int? expiresDate; - - ///Indicates if the cookie is a session only cookie. - /// - ///**NOTE**: on Android it will be always `null`. - bool? isSessionOnly; - - ///The cookie domain. - /// - ///**NOTE**: on Android it will be always `null`. - String? domain; - - ///The cookie same site policy. - /// - ///**NOTE**: on Android it will be always `null`. - HTTPCookieSameSitePolicy? sameSite; - - ///Indicates if the cookie is secure or not. - /// - ///**NOTE**: on Android it will be always `null`. - bool? isSecure; - - ///Indicates if the cookie is a http only cookie. - /// - ///**NOTE**: on Android it will be always `null`. - bool? isHttpOnly; - - ///The cookie path. - /// - ///**NOTE**: on Android it will be always `null`. - String? path; - - Cookie( - {required this.name, - required this.value, - this.expiresDate, - this.isSessionOnly, - this.domain, - this.sameSite, - this.isSecure, - this.isHttpOnly, - this.path}); - - Map toMap() { - return { - "name": name, - "value": value, - "expiresDate": expiresDate, - "isSessionOnly": isSessionOnly, - "domain": domain, - "sameSite": sameSite?.toValue(), - "isSecure": isSecure, - "isHttpOnly": isHttpOnly, - "path": path - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class used by [PermissionResponse] class. -class PermissionResponseAction { - final int _value; - - const PermissionResponseAction._internal(this._value); - - int toValue() => _value; - - ///Denies the request. - static const DENY = const PermissionResponseAction._internal(0); - - ///Grants origin the permission to access the given resources. - static const GRANT = const PermissionResponseAction._internal(1); - - ///Prompt the user for permission for the requested resource. - /// - ///**NOTE**: available only on iOS 15.0+. It will fallback to [DENY]. - static const PROMPT = const PermissionResponseAction._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class used by [PermissionRequestResponse] class. -///Use [PermissionResponseAction] instead. -@Deprecated("Use PermissionResponseAction instead") -class PermissionRequestResponseAction { - final int _value; - - const PermissionRequestResponseAction._internal(this._value); - - int toValue() => _value; - - ///Denies the request. - static const DENY = const PermissionRequestResponseAction._internal(0); - - ///Grants origin the permission to access the given resources. - static const GRANT = const PermissionRequestResponseAction._internal(1); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents a type of resource used to ask user's permission. -class PermissionResourceType { - final dynamic _value; - - const PermissionResourceType._internal(this._value); - - static final Set values = [ - PermissionResourceType.RESOURCE_AUDIO_CAPTURE, - PermissionResourceType.RESOURCE_MIDI_SYSEX, - PermissionResourceType.RESOURCE_PROTECTED_MEDIA_ID, - PermissionResourceType.RESOURCE_VIDEO_CAPTURE, - PermissionResourceType.CAMERA, - PermissionResourceType.MICROPHONE, - PermissionResourceType.CAMERA_AND_MICROPHONE, - PermissionResourceType.DEVICE_ORIENTATION_AND_MOTION, - ].toSet(); - - static final Set _androidValues = [ - PermissionResourceType.RESOURCE_AUDIO_CAPTURE, - PermissionResourceType.RESOURCE_MIDI_SYSEX, - PermissionResourceType.RESOURCE_PROTECTED_MEDIA_ID, - PermissionResourceType.RESOURCE_VIDEO_CAPTURE, - ].toSet(); - - static final Set _appleValues = - [ - PermissionResourceType.CAMERA, - PermissionResourceType.MICROPHONE, - PermissionResourceType.CAMERA_AND_MICROPHONE, - PermissionResourceType.DEVICE_ORIENTATION_AND_MOTION, - ].toSet(); - - static PermissionResourceType? fromValue(dynamic value) { - if (value != null) { - try { - Set valueList = - [].toSet(); - if (defaultTargetPlatform == TargetPlatform.android) { - valueList = PermissionResourceType._androidValues; - } else if (defaultTargetPlatform == TargetPlatform.iOS || - defaultTargetPlatform == TargetPlatform.macOS) { - valueList = PermissionResourceType._appleValues; - } - return valueList.firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - dynamic toValue() => _value; - - @override - String toString() { - if (_value is String) { - return _value; - } - switch (_value) { - case 0: - return "CAMERA"; - case 1: - return "MICROPHONE"; - case 2: - return "CAMERA_AND_MICROPHONE"; - default: - return ""; - } - } - - ///Resource belongs to audio capture device, like microphone. - /// - ///**NOTE**: available only on Android. - static const RESOURCE_AUDIO_CAPTURE = const PermissionResourceType._internal( - 'android.webkit.resource.AUDIO_CAPTURE'); - - ///Resource will allow sysex messages to be sent to or received from MIDI devices. - ///These messages are privileged operations, e.g. modifying sound libraries and sampling data, or even updating the MIDI device's firmware. - ///Permission may be requested for this resource in API levels 21 and above, if the Android device has been updated to WebView 45 or above. - /// - ///**NOTE**: available only on Android. - static const RESOURCE_MIDI_SYSEX = const PermissionResourceType._internal( - 'android.webkit.resource.MIDI_SYSEX'); - - ///Resource belongs to protected media identifier. After the user grants this resource, the origin can use EME APIs to generate the license requests. - /// - ///**NOTE**: available only on Android. - static const RESOURCE_PROTECTED_MEDIA_ID = - const PermissionResourceType._internal( - 'android.webkit.resource.PROTECTED_MEDIA_ID'); - - ///Resource belongs to video capture device, like camera. - /// - ///**NOTE**: available only on Android. - static const RESOURCE_VIDEO_CAPTURE = const PermissionResourceType._internal( - 'android.webkit.resource.VIDEO_CAPTURE'); - - ///A media device that can capture video. - /// - ///**NOTE**: available only on iOS. - static const CAMERA = const PermissionResourceType._internal(0); - - ///A media device that can capture audio. - /// - ///**NOTE**: available only on iOS. - static const MICROPHONE = const PermissionResourceType._internal(1); - - ///A media device or devices that can capture audio and video. - /// - ///**NOTE**: available only on iOS. - static const CAMERA_AND_MICROPHONE = - const PermissionResourceType._internal(2); - - ///Resource belongs to the device’s orientation and motion. - /// - ///**NOTE**: available only on iOS. - static const DEVICE_ORIENTATION_AND_MOTION = - const PermissionResourceType._internal('deviceOrientationAndMotion'); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents the response used by the [WebView.onPermissionRequest] event. -class PermissionRequest { - ///The origin of web content which attempt to access the restricted resources. - Uri origin; - - ///List of resources the web content wants to access. - /// - ///**NOTE for iOS**: this list will have only 1 element and will be used by the [PermissionResponse.action] - ///as the resource to consider when applying the corresponding action. - List resources; - - ///The frame that initiates the request in the web view. - FrameInfo? frame; - - PermissionRequest( - {required this.origin, this.resources = const [], this.frame}); - - static PermissionRequest? fromMap(Map? map) { - if (map == null) { - return null; - } - - List resources = []; - if (map["resources"] != null) { - (map["resources"].cast() as List).forEach((element) { - var resource = PermissionResourceType.fromValue(element); - if (resource != null) { - resources.add(resource); - } - }); - } - - return PermissionRequest( - origin: Uri.parse(map["origin"]), - resources: resources, - frame: FrameInfo.fromMap(map["frame"]?.cast())); - } - - Map toMap() { - return { - "origin": origin.toString(), - "resources": resources.map((e) => e.toValue()).toList(), - "frame": frame?.toMap() - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents the response used by the [WebView.onPermissionRequest] event. -class PermissionResponse { - ///Resources granted to be accessed by origin. - /// - ///**NOTE for iOS**: not used. The [action] taken is based on the [PermissionRequest.resources]. - List resources; - - ///Indicate the [PermissionResponseAction] to take in response of a permission request. - PermissionResponseAction? action; - - PermissionResponse( - {this.resources = const [], this.action = PermissionResponseAction.DENY}); - - Map toMap() { - return { - "resources": resources.map((e) => e.toValue()).toList(), - "action": action?.toValue() - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents the response used by the [WebView.androidOnPermissionRequest] event. -///Use [PermissionResponse] instead. -@Deprecated("Use PermissionResponse instead") -class PermissionRequestResponse { - ///Resources granted to be accessed by origin. - List resources; - - ///Indicate the [PermissionRequestResponseAction] to take in response of a permission request. - PermissionRequestResponseAction? action; - - PermissionRequestResponse( - {this.resources = const [], - this.action = PermissionRequestResponseAction.DENY}); - - Map toMap() { - return {"resources": resources, "action": action?.toValue()}; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that is used by [WebView.shouldOverrideUrlLoading] event. -///It represents the policy to pass back to the decision handler. -class NavigationActionPolicy { - final int _value; - - const NavigationActionPolicy._internal(this._value); - - int toValue() => _value; - - ///Cancel the navigation. - static const CANCEL = const NavigationActionPolicy._internal(0); - - ///Allow the navigation to continue. - static const ALLOW = const NavigationActionPolicy._internal(1); - - ///Turn the navigation into a download. - /// - ///**NOTE**: available only on iOS 14.5+. It will fallback to [CANCEL]. - static const DOWNLOAD = const NavigationActionPolicy._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; - - Map toMap() { - return { - "action": _value, - }; - } -} - -///Class that represents the type of action triggering a navigation for the [WebView.shouldOverrideUrlLoading] event. -class NavigationType { - final int _value; - - const NavigationType._internal(this._value); - - static final Set values = [ - NavigationType.LINK_ACTIVATED, - NavigationType.FORM_SUBMITTED, - NavigationType.BACK_FORWARD, - NavigationType.RELOAD, - NavigationType.FORM_RESUBMITTED, - NavigationType.OTHER, - ].toSet(); - - static NavigationType? fromValue(int? value) { - if (value != null) { - try { - return NavigationType.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - ///A link with an href attribute was activated by the user. - static const LINK_ACTIVATED = const NavigationType._internal(0); - - ///A form was submitted. - static const FORM_SUBMITTED = const NavigationType._internal(1); - - ///An item from the back-forward list was requested. - static const BACK_FORWARD = const NavigationType._internal(2); - - ///The webpage was reloaded. - static const RELOAD = const NavigationType._internal(3); - - ///A form was resubmitted (for example by going back, going forward, or reloading). - static const FORM_RESUBMITTED = const NavigationType._internal(4); - - ///Navigation is taking place for some other reason. - static const OTHER = const NavigationType._internal(-1); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; - - @override - String toString() { - switch (_value) { - case 0: - return "LINK_ACTIVATED"; - case 1: - return "FORM_SUBMITTED"; - case 2: - return "BACK_FORWARD"; - case 3: - return "RELOAD"; - case 4: - return "FORM_RESUBMITTED"; - case -1: - default: - return "OTHER"; - } - } -} - -///Class that represents the type of action triggering a navigation on iOS for the [WebView.shouldOverrideUrlLoading] event. -///Use [NavigationType] instead. -@Deprecated("Use NavigationType instead") -class IOSWKNavigationType { - final int _value; - - const IOSWKNavigationType._internal(this._value); - - static final Set values = [ - IOSWKNavigationType.LINK_ACTIVATED, - IOSWKNavigationType.FORM_SUBMITTED, - IOSWKNavigationType.BACK_FORWARD, - IOSWKNavigationType.RELOAD, - IOSWKNavigationType.FORM_RESUBMITTED, - IOSWKNavigationType.OTHER, - ].toSet(); - - static IOSWKNavigationType? fromValue(int? value) { - if (value != null) { - try { - return IOSWKNavigationType.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - ///A link with an href attribute was activated by the user. - static const LINK_ACTIVATED = const IOSWKNavigationType._internal(0); - - ///A form was submitted. - static const FORM_SUBMITTED = const IOSWKNavigationType._internal(1); - - ///An item from the back-forward list was requested. - static const BACK_FORWARD = const IOSWKNavigationType._internal(2); - - ///The webpage was reloaded. - static const RELOAD = const IOSWKNavigationType._internal(3); - - ///A form was resubmitted (for example by going back, going forward, or reloading). - static const FORM_RESUBMITTED = const IOSWKNavigationType._internal(4); - - ///Navigation is taking place for some other reason. - static const OTHER = const IOSWKNavigationType._internal(-1); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; - - @override - String toString() { - switch (_value) { - case 0: - return "LINK_ACTIVATED"; - case 1: - return "FORM_SUBMITTED"; - case 2: - return "BACK_FORWARD"; - case 3: - return "RELOAD"; - case 4: - return "FORM_RESUBMITTED"; - case -1: - default: - return "OTHER"; - } - } -} - -///Class that represents the constants used to specify interaction with the cached responses. -class URLRequestCachePolicy { - final int _value; - - const URLRequestCachePolicy._internal(this._value); - - static final Set values = [ - URLRequestCachePolicy.USE_PROTOCOL_CACHE_POLICY, - URLRequestCachePolicy.RELOAD_IGNORING_LOCAL_CACHE_DATA, - URLRequestCachePolicy.RELOAD_IGNORING_LOCAL_AND_REMOTE_CACHE_DATA, - URLRequestCachePolicy.RETURN_CACHE_DATA_ELSE_LOAD, - URLRequestCachePolicy.RETURN_CACHE_DATA_DONT_LOAD, - URLRequestCachePolicy.RELOAD_REVALIDATING_CACHE_DATA, - ].toSet(); - - static URLRequestCachePolicy? fromValue(int? value) { - if (value != null) { - try { - return URLRequestCachePolicy.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "RELOAD_IGNORING_LOCAL_CACHE_DATA"; - case 2: - return "RETURN_CACHE_DATA_ELSE_LOAD"; - case 3: - return "RETURN_CACHE_DATA_DONT_LOAD"; - case 4: - return "RELOAD_IGNORING_LOCAL_AND_REMOTE_CACHE_DATA"; - case 5: - return "RELOAD_REVALIDATING_CACHE_DATA"; - case 0: - default: - return "USE_PROTOCOL_CACHE_POLICY"; - } - } - - ///Use the caching logic defined in the protocol implementation, if any, for a particular URL load request. - ///This is the default policy for URL load requests. - static const USE_PROTOCOL_CACHE_POLICY = - const URLRequestCachePolicy._internal(0); - - ///The URL load should be loaded only from the originating source. - ///This policy specifies that no existing cache data should be used to satisfy a URL load request. - /// - ///**NOTE**: Always use this policy if you are making HTTP or HTTPS byte-range requests. - static const RELOAD_IGNORING_LOCAL_CACHE_DATA = - const URLRequestCachePolicy._internal(1); - - ///Use existing cache data, regardless or age or expiration date, loading from originating source only if there is no cached data. - static const RETURN_CACHE_DATA_ELSE_LOAD = - const URLRequestCachePolicy._internal(2); - - ///Use existing cache data, regardless or age or expiration date, and fail if no cached data is available. - /// - ///If there is no existing data in the cache corresponding to a URL load request, - ///no attempt is made to load the data from the originating source, and the load is considered to have failed. - ///This constant specifies a behavior that is similar to an “offline” mode. - static const RETURN_CACHE_DATA_DONT_LOAD = - const URLRequestCachePolicy._internal(3); - - ///Ignore local cache data, and instruct proxies and other intermediates to disregard their caches so far as the protocol allows. - /// - ///**NOTE**: Versions earlier than macOS 15, iOS 13, watchOS 6, and tvOS 13 don’t implement this constant. - static const RELOAD_IGNORING_LOCAL_AND_REMOTE_CACHE_DATA = - const URLRequestCachePolicy._internal(4); - - ///Use cache data if the origin source can validate it; otherwise, load from the origin. - /// - ///**NOTE**: Versions earlier than macOS 15, iOS 13, watchOS 6, and tvOS 13 don’t implement this constant. - static const RELOAD_REVALIDATING_CACHE_DATA = - const URLRequestCachePolicy._internal(5); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///An iOS-specific Class that represents the constants used to specify interaction with the cached responses. -///Use [URLRequestCachePolicy] instead. -@Deprecated("Use URLRequestCachePolicy instead") -class IOSURLRequestCachePolicy { - final int _value; - - const IOSURLRequestCachePolicy._internal(this._value); - - static final Set values = [ - IOSURLRequestCachePolicy.USE_PROTOCOL_CACHE_POLICY, - IOSURLRequestCachePolicy.RELOAD_IGNORING_LOCAL_CACHE_DATA, - IOSURLRequestCachePolicy.RELOAD_IGNORING_LOCAL_AND_REMOTE_CACHE_DATA, - IOSURLRequestCachePolicy.RETURN_CACHE_DATA_ELSE_LOAD, - IOSURLRequestCachePolicy.RETURN_CACHE_DATA_DONT_LOAD, - IOSURLRequestCachePolicy.RELOAD_REVALIDATING_CACHE_DATA, - ].toSet(); - - static IOSURLRequestCachePolicy? fromValue(int? value) { - if (value != null) { - try { - return IOSURLRequestCachePolicy.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "RELOAD_IGNORING_LOCAL_CACHE_DATA"; - case 2: - return "RETURN_CACHE_DATA_ELSE_LOAD"; - case 3: - return "RETURN_CACHE_DATA_DONT_LOAD"; - case 4: - return "RELOAD_IGNORING_LOCAL_AND_REMOTE_CACHE_DATA"; - case 5: - return "RELOAD_REVALIDATING_CACHE_DATA"; - case 0: - default: - return "USE_PROTOCOL_CACHE_POLICY"; - } - } - - ///Use the caching logic defined in the protocol implementation, if any, for a particular URL load request. - ///This is the default policy for URL load requests. - static const USE_PROTOCOL_CACHE_POLICY = - const IOSURLRequestCachePolicy._internal(0); - - ///The URL load should be loaded only from the originating source. - ///This policy specifies that no existing cache data should be used to satisfy a URL load request. - /// - ///**NOTE**: Always use this policy if you are making HTTP or HTTPS byte-range requests. - static const RELOAD_IGNORING_LOCAL_CACHE_DATA = - const IOSURLRequestCachePolicy._internal(1); - - ///Use existing cache data, regardless or age or expiration date, loading from originating source only if there is no cached data. - static const RETURN_CACHE_DATA_ELSE_LOAD = - const IOSURLRequestCachePolicy._internal(2); - - ///Use existing cache data, regardless or age or expiration date, and fail if no cached data is available. - /// - ///If there is no existing data in the cache corresponding to a URL load request, - ///no attempt is made to load the data from the originating source, and the load is considered to have failed. - ///This constant specifies a behavior that is similar to an “offline” mode. - static const RETURN_CACHE_DATA_DONT_LOAD = - const IOSURLRequestCachePolicy._internal(3); - - ///Ignore local cache data, and instruct proxies and other intermediates to disregard their caches so far as the protocol allows. - /// - ///**NOTE**: Versions earlier than macOS 15, iOS 13, watchOS 6, and tvOS 13 don’t implement this constant. - static const RELOAD_IGNORING_LOCAL_AND_REMOTE_CACHE_DATA = - const IOSURLRequestCachePolicy._internal(4); - - ///Use cache data if the origin source can validate it; otherwise, load from the origin. - /// - ///**NOTE**: Versions earlier than macOS 15, iOS 13, watchOS 6, and tvOS 13 don’t implement this constant. - static const RELOAD_REVALIDATING_CACHE_DATA = - const IOSURLRequestCachePolicy._internal(5); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents the constants that specify how a request uses network resources. -class URLRequestNetworkServiceType { - final int _value; - - const URLRequestNetworkServiceType._internal(this._value); - - static final Set values = [ - URLRequestNetworkServiceType.DEFAULT, - URLRequestNetworkServiceType.VIDEO, - URLRequestNetworkServiceType.BACKGROUND, - URLRequestNetworkServiceType.VOICE, - URLRequestNetworkServiceType.RESPONSIVE_DATA, - URLRequestNetworkServiceType.AV_STREAMING, - URLRequestNetworkServiceType.RESPONSIVE_AV, - URLRequestNetworkServiceType.CALL_SIGNALING, - ].toSet(); - - static URLRequestNetworkServiceType? fromValue(int? value) { - if (value != null) { - try { - return URLRequestNetworkServiceType.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 2: - return "VIDEO"; - case 3: - return "BACKGROUND"; - case 4: - return "VOICE"; - case 6: - return "RESPONSIVE_DATA"; - case 8: - return "AV_STREAMING"; - case 9: - return "RESPONSIVE_AV"; - case 11: - return "CALL_SIGNALING"; - case 0: - default: - return "DEFAULT"; - } - } - - ///A service type for standard network traffic. - static const DEFAULT = const URLRequestNetworkServiceType._internal(0); - - ///A service type for video traffic. - static const VIDEO = const URLRequestNetworkServiceType._internal(2); - - ///A service type for background traffic. - /// - ///You should specify this type if your app is performing a download that was not requested by the user—for example, - ///prefetching content so that it will be available when the user chooses to view it. - static const BACKGROUND = const URLRequestNetworkServiceType._internal(3); - - ///A service type for voice traffic. - static const VOICE = const URLRequestNetworkServiceType._internal(4); - - ///A service type for data that the user is actively waiting for. - /// - ///Use this service type for interactive situations where the user is anticipating a quick response, like instant messaging or completing a purchase. - static const RESPONSIVE_DATA = - const URLRequestNetworkServiceType._internal(6); - - ///A service type for streaming audio/video data. - static const AV_STREAMING = const URLRequestNetworkServiceType._internal(8); - - ///A service type for responsive (time-sensitive) audio/video data. - static const RESPONSIVE_AV = const URLRequestNetworkServiceType._internal(9); - - ///A service type for call signaling. - /// - ///Use this service type with network traffic that establishes, maintains, or tears down a VoIP call. - static const CALL_SIGNALING = - const URLRequestNetworkServiceType._internal(11); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///An iOS-specific Class that represents the constants that specify how a request uses network resources. -///Use [URLRequestNetworkServiceType] instead. -@Deprecated("Use URLRequestNetworkServiceType instead") -class IOSURLRequestNetworkServiceType { - final int _value; - - const IOSURLRequestNetworkServiceType._internal(this._value); - - static final Set values = [ - IOSURLRequestNetworkServiceType.DEFAULT, - IOSURLRequestNetworkServiceType.VIDEO, - IOSURLRequestNetworkServiceType.BACKGROUND, - IOSURLRequestNetworkServiceType.VOICE, - IOSURLRequestNetworkServiceType.RESPONSIVE_DATA, - IOSURLRequestNetworkServiceType.AV_STREAMING, - IOSURLRequestNetworkServiceType.RESPONSIVE_AV, - IOSURLRequestNetworkServiceType.CALL_SIGNALING, - ].toSet(); - - static IOSURLRequestNetworkServiceType? fromValue(int? value) { - if (value != null) { - try { - return IOSURLRequestNetworkServiceType.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 2: - return "VIDEO"; - case 3: - return "BACKGROUND"; - case 4: - return "VOICE"; - case 6: - return "RESPONSIVE_DATA"; - case 8: - return "AV_STREAMING"; - case 9: - return "RESPONSIVE_AV"; - case 11: - return "CALL_SIGNALING"; - case 0: - default: - return "DEFAULT"; - } - } - - ///A service type for standard network traffic. - static const DEFAULT = const IOSURLRequestNetworkServiceType._internal(0); - - ///A service type for video traffic. - static const VIDEO = const IOSURLRequestNetworkServiceType._internal(2); - - ///A service type for background traffic. - /// - ///You should specify this type if your app is performing a download that was not requested by the user—for example, - ///prefetching content so that it will be available when the user chooses to view it. - static const BACKGROUND = const IOSURLRequestNetworkServiceType._internal(3); - - ///A service type for voice traffic. - static const VOICE = const IOSURLRequestNetworkServiceType._internal(4); - - ///A service type for data that the user is actively waiting for. - /// - ///Use this service type for interactive situations where the user is anticipating a quick response, like instant messaging or completing a purchase. - static const RESPONSIVE_DATA = - const IOSURLRequestNetworkServiceType._internal(6); - - ///A service type for streaming audio/video data. - static const AV_STREAMING = - const IOSURLRequestNetworkServiceType._internal(8); - - ///A service type for responsive (time-sensitive) audio/video data. - static const RESPONSIVE_AV = - const IOSURLRequestNetworkServiceType._internal(9); - - ///A service type for call signaling. - /// - ///Use this service type with network traffic that establishes, maintains, or tears down a VoIP call. - static const CALL_SIGNALING = - const IOSURLRequestNetworkServiceType._internal(11); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///An object that identifies the origin of a particular resource. -/// -///**NOTE**: available only on iOS 9.0+. -class SecurityOrigin { - ///The security origin’s host. - String host; - - ///The security origin's port. - int port; - - ///The security origin's protocol. - String protocol; - - SecurityOrigin( - {required this.host, required this.port, required this.protocol}); - - static SecurityOrigin? fromMap(Map? map) { - if (map == null) { - return null; - } - return SecurityOrigin( - host: map["host"], port: map["port"], protocol: map["protocol"]); - } - - Map toMap() { - return {"host": host, "port": port, "protocol": protocol}; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///An object that identifies the origin of a particular resource. -/// -///**NOTE**: available only on iOS 9.0+. -/// -///Use [SecurityOrigin] instead. -@Deprecated("Use SecurityOrigin instead") -class IOSWKSecurityOrigin { - ///The security origin’s host. - String host; - - ///The security origin's port. - int port; - - ///The security origin's protocol. - String protocol; - - IOSWKSecurityOrigin( - {required this.host, required this.port, required this.protocol}); - - static IOSWKSecurityOrigin? fromMap(Map? map) { - if (map == null) { - return null; - } - return IOSWKSecurityOrigin( - host: map["host"], port: map["port"], protocol: map["protocol"]); - } - - Map toMap() { - return {"host": host, "port": port, "protocol": protocol}; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///An object that contains information about a frame on a webpage. -/// -///**NOTE**: available only on iOS. -class FrameInfo { - ///A Boolean value indicating whether the frame is the web site's main frame or a subframe. - bool isMainFrame; - - ///The frame’s current request. - URLRequest? request; - - ///The frame’s security origin. - SecurityOrigin? securityOrigin; - - FrameInfo( - {required this.isMainFrame, required this.request, this.securityOrigin}); - - static FrameInfo? fromMap(Map? map) { - if (map == null) { - return null; - } - return FrameInfo( - isMainFrame: map["isMainFrame"], - request: URLRequest.fromMap(map["request"]?.cast()), - securityOrigin: SecurityOrigin.fromMap( - map["securityOrigin"]?.cast())); - } - - Map toMap() { - return { - "isMainFrame": isMainFrame, - "request": request?.toMap(), - "securityOrigin": securityOrigin?.toMap() - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///An object that contains information about a frame on a webpage. -/// -///**NOTE**: available only on iOS. -/// -///Use [FrameInfo] instead. -@Deprecated("Use FrameInfo instead") -class IOSWKFrameInfo { - ///A Boolean value indicating whether the frame is the web site's main frame or a subframe. - bool isMainFrame; - - ///The frame’s current request. - URLRequest? request; - - ///The frame’s security origin. - IOSWKSecurityOrigin? securityOrigin; - - IOSWKFrameInfo( - {required this.isMainFrame, required this.request, this.securityOrigin}); - - static IOSWKFrameInfo? fromMap(Map? map) { - if (map == null) { - return null; - } - return IOSWKFrameInfo( - isMainFrame: map["isMainFrame"], - request: URLRequest.fromMap(map["request"]?.cast()), - securityOrigin: IOSWKSecurityOrigin.fromMap( - map["securityOrigin"]?.cast())); - } - - Map toMap() { - return { - "isMainFrame": isMainFrame, - "request": request?.toMap(), - "securityOrigin": securityOrigin?.toMap() - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///An object that contains information about an action that causes navigation to occur. -class NavigationAction { - ///The URL request object associated with the navigation action. - /// - ///**NOTE for Android**: If the request is associated to the [WebView.onCreateWindow] event - ///and the window has been created using JavaScript, [request.url] will be `null`, - ///the [request.method] is always `GET`, and [request.headers] value is always `null`. - ///Also, on Android < 21, the [request.method] is always `GET` and [request.headers] value is always `null`. - URLRequest request; - - ///Indicates whether the request was made for the main frame. - /// - ///**NOTE for Android**: If the request is associated to the [WebView.onCreateWindow] event, this is always `true`. - ///Also, on Android < 21, this is always `true`. - bool isForMainFrame; - - ///Use [hasGesture] instead. - @Deprecated('Use hasGesture instead') - bool? androidHasGesture; - - ///Gets whether a gesture (such as a click) was associated with the request. - ///For security reasons in certain situations this method may return `false` even though - ///the sequence of events which caused the request to be created was initiated by a user - ///gesture. - /// - ///**NOTE**: available only on Android. On Android < 24, this is always `false`. - bool? hasGesture; - - ///Use [isRedirect] instead. - @Deprecated('Use isRedirect instead') - bool? androidIsRedirect; - - ///Gets whether the request was a result of a server-side redirect. - /// - ///**NOTE**: available only on Android. - ///If the request is associated to the [WebView.onCreateWindow] event, this is always `false`. - ///Also, on Android < 21, this is always `false`. - bool? isRedirect; - - ///Use [navigationType] instead. - @Deprecated("Use navigationType instead") - IOSWKNavigationType? iosWKNavigationType; - - ///The type of action triggering the navigation. - /// - ///**NOTE**: available only on iOS. - NavigationType? navigationType; - - ///Use [sourceFrame] instead. - @Deprecated("Use sourceFrame instead") - IOSWKFrameInfo? iosSourceFrame; - - ///The frame that requested the navigation. - /// - ///**NOTE**: available only on iOS. - FrameInfo? sourceFrame; - - ///Use [targetFrame] instead. - @Deprecated("Use targetFrame instead") - IOSWKFrameInfo? iosTargetFrame; - - ///The frame in which to display the new content. - /// - ///**NOTE**: available only on iOS. - FrameInfo? targetFrame; - - ///A value indicating whether the web content used a download attribute to indicate that this should be downloaded. - /// - ///**NOTE**: available only on iOS. - bool? shouldPerformDownload; - - NavigationAction( - {required this.request, - required this.isForMainFrame, - @Deprecated('Use hasGesture instead') this.androidHasGesture, - this.hasGesture, - @Deprecated('Use isRedirect instead') this.androidIsRedirect, - this.isRedirect, - @Deprecated("Use navigationType instead") this.iosWKNavigationType, - this.navigationType, - @Deprecated("Use sourceFrame instead") this.iosSourceFrame, - this.sourceFrame, - @Deprecated("Use targetFrame instead") this.iosTargetFrame, - this.targetFrame, - this.shouldPerformDownload}) { - // ignore: deprecated_member_use_from_same_package - this.hasGesture = this.hasGesture ?? this.androidHasGesture; - // ignore: deprecated_member_use_from_same_package - this.isRedirect = this.isRedirect ?? this.androidIsRedirect; - this.navigationType = this.navigationType ?? - // ignore: deprecated_member_use_from_same_package - NavigationType.fromValue(this.iosWKNavigationType?.toValue()); - this.sourceFrame = - // ignore: deprecated_member_use_from_same_package - this.sourceFrame ?? FrameInfo.fromMap(this.iosSourceFrame?.toMap()); - this.targetFrame = - // ignore: deprecated_member_use_from_same_package - this.targetFrame ?? FrameInfo.fromMap(this.iosTargetFrame?.toMap()); - } - - static NavigationAction? fromMap(Map? map) { - if (map == null) { - return null; - } - return NavigationAction( - request: URLRequest.fromMap(map["request"].cast())!, - isForMainFrame: map["isForMainFrame"], - // ignore: deprecated_member_use_from_same_package - androidHasGesture: map["hasGesture"] ?? map["androidHasGesture"], - hasGesture: map["hasGesture"], - // ignore: deprecated_member_use_from_same_package - androidIsRedirect: map["isRedirect"] ?? map["androidIsRedirect"], - isRedirect: map["isRedirect"], - // ignore: deprecated_member_use_from_same_package - iosWKNavigationType: - // ignore: deprecated_member_use_from_same_package - IOSWKNavigationType.fromValue(map["navigationType"]), - navigationType: NavigationType.fromValue(map["navigationType"]), - // ignore: deprecated_member_use_from_same_package - iosSourceFrame: - // ignore: deprecated_member_use_from_same_package - IOSWKFrameInfo.fromMap(map["sourceFrame"]?.cast()), - sourceFrame: - FrameInfo.fromMap(map["sourceFrame"]?.cast()), - // ignore: deprecated_member_use_from_same_package - iosTargetFrame: - // ignore: deprecated_member_use_from_same_package - IOSWKFrameInfo.fromMap(map["targetFrame"]?.cast()), - targetFrame: - FrameInfo.fromMap(map["targetFrame"]?.cast()), - shouldPerformDownload: map["shouldPerformDownload"]); - } - - Map toMap() { - return { - "request": request.toMap(), - "isForMainFrame": isForMainFrame, - // ignore: deprecated_member_use_from_same_package - "androidHasGesture": hasGesture ?? androidHasGesture, - // ignore: deprecated_member_use_from_same_package - "hasGesture": hasGesture ?? androidHasGesture, - // ignore: deprecated_member_use_from_same_package - "isRedirect": isRedirect ?? androidIsRedirect, - // ignore: deprecated_member_use_from_same_package - "androidIsRedirect": isRedirect ?? androidIsRedirect, - "iosWKNavigationType": - // ignore: deprecated_member_use_from_same_package - navigationType?.toValue() ?? iosWKNavigationType?.toValue(), - "navigationType": - // ignore: deprecated_member_use_from_same_package - navigationType?.toValue() ?? iosWKNavigationType?.toValue(), - // ignore: deprecated_member_use_from_same_package - "iosSourceFrame": sourceFrame?.toMap() ?? iosSourceFrame?.toMap(), - // ignore: deprecated_member_use_from_same_package - "sourceFrame": sourceFrame?.toMap() ?? iosSourceFrame?.toMap(), - // ignore: deprecated_member_use_from_same_package - "iosTargetFrame": targetFrame?.toMap() ?? iosTargetFrame?.toMap(), - // ignore: deprecated_member_use_from_same_package - "targetFrame": targetFrame?.toMap() ?? iosTargetFrame?.toMap(), - "shouldPerformDownload": shouldPerformDownload - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents the navigation request used by the [WebView.onCreateWindow] event. -class CreateWindowAction extends NavigationAction { - ///The window id. Used by [WebView] to create a new WebView. - int windowId; - - ///Use [isDialog] instead. - @Deprecated("Use isDialog instead") - bool? androidIsDialog; - - ///Indicates if the new window should be a dialog, rather than a full-size window. - /// - ///**NOTE**: available only on Android. - bool? isDialog; - - ///Use [windowFeatures] instead. - @Deprecated("Use windowFeatures instead") - IOSWKWindowFeatures? iosWindowFeatures; - - ///Window features requested by the webpage. - /// - ///**NOTE**: available only on iOS. - WindowFeatures? windowFeatures; - - CreateWindowAction( - {required this.windowId, - @Deprecated('Use isDialog instead') - this.androidIsDialog, - this.isDialog, - @Deprecated('Use windowFeatures instead') - this.iosWindowFeatures, - this.windowFeatures, - required URLRequest request, - required bool isForMainFrame, - @Deprecated('Use hasGesture instead') - bool? androidHasGesture, - @Deprecated('Use isRedirect instead') - bool? androidIsRedirect, - bool? hasGesture, - bool? isRedirect, - @Deprecated('Use navigationType instead') - // ignore: deprecated_member_use_from_same_package - IOSWKNavigationType? iosWKNavigationType, - NavigationType? navigationType, - @Deprecated('Use sourceFrame instead') - // ignore: deprecated_member_use_from_same_package - IOSWKFrameInfo? iosSourceFrame, - FrameInfo? sourceFrame, - @Deprecated('Use targetFrame instead') - // ignore: deprecated_member_use_from_same_package - IOSWKFrameInfo? iosTargetFrame, - FrameInfo? targetFrame}) - : super( - request: request, - isForMainFrame: isForMainFrame, - // ignore: deprecated_member_use_from_same_package - androidHasGesture: hasGesture ?? androidHasGesture, - hasGesture: hasGesture ?? androidHasGesture, - // ignore: deprecated_member_use_from_same_package - androidIsRedirect: isRedirect ?? androidIsRedirect, - isRedirect: isRedirect ?? androidIsRedirect, - // ignore: deprecated_member_use_from_same_package - iosWKNavigationType: - // ignore: deprecated_member_use_from_same_package - IOSWKNavigationType.fromValue(navigationType?.toValue()) ?? - iosWKNavigationType, - navigationType: navigationType ?? - NavigationType.fromValue(iosWKNavigationType?.toValue()), - // ignore: deprecated_member_use_from_same_package - iosSourceFrame: - // ignore: deprecated_member_use_from_same_package - IOSWKFrameInfo.fromMap(sourceFrame?.toMap()) ?? iosSourceFrame, - sourceFrame: - sourceFrame ?? FrameInfo.fromMap(iosSourceFrame?.toMap()), - // ignore: deprecated_member_use_from_same_package - iosTargetFrame: - // ignore: deprecated_member_use_from_same_package - IOSWKFrameInfo.fromMap(targetFrame?.toMap()) ?? iosTargetFrame, - targetFrame: - targetFrame ?? FrameInfo.fromMap(iosTargetFrame?.toMap())) { - // ignore: deprecated_member_use_from_same_package - this.isDialog = this.isDialog ?? this.androidIsDialog; - this.windowFeatures = this.windowFeatures ?? - // ignore: deprecated_member_use_from_same_package - WindowFeatures.fromMap(this.iosWindowFeatures?.toMap()); - } - - static CreateWindowAction? fromMap(Map? map) { - if (map == null) { - return null; - } - return CreateWindowAction( - windowId: map["windowId"], - // ignore: deprecated_member_use_from_same_package - androidIsDialog: map["isDialog"] ?? map["androidIsDialog"], - isDialog: map["isDialog"] ?? map["androidIsDialog"], - // ignore: deprecated_member_use_from_same_package - iosWindowFeatures: IOSWKWindowFeatures.fromMap( - map["windowFeatures"]?.cast()), - windowFeatures: WindowFeatures.fromMap( - map["windowFeatures"]?.cast()), - request: URLRequest.fromMap(map["request"].cast())!, - isForMainFrame: map["isForMainFrame"], - // ignore: deprecated_member_use_from_same_package - androidHasGesture: map["hasGesture"], - hasGesture: map["hasGesture"], - // ignore: deprecated_member_use_from_same_package - androidIsRedirect: map["isRedirect"], - isRedirect: map["isRedirect"], - // ignore: deprecated_member_use_from_same_package - iosWKNavigationType: - // ignore: deprecated_member_use_from_same_package - IOSWKNavigationType.fromValue(map["navigationType"]), - navigationType: NavigationType.fromValue(map["navigationType"]), - // ignore: deprecated_member_use_from_same_package - iosSourceFrame: - // ignore: deprecated_member_use_from_same_package - IOSWKFrameInfo.fromMap(map["sourceFrame"]?.cast()), - sourceFrame: - FrameInfo.fromMap(map["sourceFrame"]?.cast()), - // ignore: deprecated_member_use_from_same_package - iosTargetFrame: - // ignore: deprecated_member_use_from_same_package - IOSWKFrameInfo.fromMap(map["targetFrame"]?.cast()), - targetFrame: - FrameInfo.fromMap(map["targetFrame"]?.cast())); - } - - @override - Map toMap() { - var createWindowActionMap = super.toMap(); - createWindowActionMap.addAll({ - "windowId": windowId, - // ignore: deprecated_member_use_from_same_package - "androidIsDialog": isDialog ?? androidIsDialog, - // ignore: deprecated_member_use_from_same_package - "isDialog": isDialog ?? androidIsDialog, - "iosWindowFeatures": - // ignore: deprecated_member_use_from_same_package - windowFeatures?.toMap() ?? iosWindowFeatures?.toMap(), - // ignore: deprecated_member_use_from_same_package - "windowFeatures": windowFeatures?.toMap() ?? iosWindowFeatures?.toMap(), - }); - return createWindowActionMap; - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that encapsulates information about the amount of storage currently used by an origin for the JavaScript storage APIs. -///An origin comprises the host, scheme and port of a URI. See [WebStorageManager] for details. -class WebStorageOrigin { - ///The string representation of this origin. - String? origin; - - ///The quota for this origin, for the Web SQL Database API, in bytes. - int? quota; - - ///The total amount of storage currently being used by this origin, for all JavaScript storage APIs, in bytes. - int? usage; - - WebStorageOrigin({this.origin, this.quota, this.usage}); - - Map toMap() { - return {"origin": origin, "quota": quota, "usage": usage}; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that encapsulates information about the amount of storage currently used by an origin for the JavaScript storage APIs. -///An origin comprises the host, scheme and port of a URI. See [AndroidWebStorageManager] for details. -///Use [WebStorageOrigin] instead. -@Deprecated("Use WebStorageOrigin instead") -class AndroidWebStorageOrigin { - ///The string representation of this origin. - String? origin; - - ///The quota for this origin, for the Web SQL Database API, in bytes. - int? quota; - - ///The total amount of storage currently being used by this origin, for all JavaScript storage APIs, in bytes. - int? usage; - - AndroidWebStorageOrigin({this.origin, this.quota, this.usage}); - - Map toMap() { - return {"origin": origin, "quota": quota, "usage": usage}; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents a website data type. -/// -///**NOTE**: available on iOS 9.0+. -class WebsiteDataType { - final String _value; - - const WebsiteDataType._internal(this._value); - - static final Set values = [ - WebsiteDataType.WKWebsiteDataTypeFetchCache, - WebsiteDataType.WKWebsiteDataTypeDiskCache, - WebsiteDataType.WKWebsiteDataTypeMemoryCache, - WebsiteDataType.WKWebsiteDataTypeOfflineWebApplicationCache, - WebsiteDataType.WKWebsiteDataTypeCookies, - WebsiteDataType.WKWebsiteDataTypeSessionStorage, - WebsiteDataType.WKWebsiteDataTypeLocalStorage, - WebsiteDataType.WKWebsiteDataTypeWebSQLDatabases, - WebsiteDataType.WKWebsiteDataTypeIndexedDBDatabases, - WebsiteDataType.WKWebsiteDataTypeServiceWorkerRegistrations, - ].toSet(); - - static WebsiteDataType? fromValue(String? value) { - if (value != null) { - try { - return WebsiteDataType.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - String toValue() => _value; - - @override - String toString() => _value; - - ///On-disk Fetch caches. - /// - ///**NOTE**: available on iOS 11.3+. - static const WKWebsiteDataTypeFetchCache = - const WebsiteDataType._internal("WKWebsiteDataTypeFetchCache"); - - ///On-disk caches. - static const WKWebsiteDataTypeDiskCache = - const WebsiteDataType._internal("WKWebsiteDataTypeDiskCache"); - - ///In-memory caches. - static const WKWebsiteDataTypeMemoryCache = - const WebsiteDataType._internal("WKWebsiteDataTypeMemoryCache"); - - ///HTML offline web application caches. - static const WKWebsiteDataTypeOfflineWebApplicationCache = - const WebsiteDataType._internal( - "WKWebsiteDataTypeOfflineWebApplicationCache"); - - ///Cookies. - static const WKWebsiteDataTypeCookies = - const WebsiteDataType._internal("WKWebsiteDataTypeCookies"); - - ///HTML session storage. - static const WKWebsiteDataTypeSessionStorage = - const WebsiteDataType._internal("WKWebsiteDataTypeSessionStorage"); - - ///HTML local storage. - static const WKWebsiteDataTypeLocalStorage = - const WebsiteDataType._internal("WKWebsiteDataTypeLocalStorage"); - - ///WebSQL databases. - static const WKWebsiteDataTypeWebSQLDatabases = - const WebsiteDataType._internal("WKWebsiteDataTypeWebSQLDatabases"); - - ///IndexedDB databases. - static const WKWebsiteDataTypeIndexedDBDatabases = - const WebsiteDataType._internal("WKWebsiteDataTypeIndexedDBDatabases"); - - ///Service worker registrations. - /// - ///**NOTE**: available on iOS 11.3+. - static const WKWebsiteDataTypeServiceWorkerRegistrations = - const WebsiteDataType._internal( - "WKWebsiteDataTypeServiceWorkerRegistrations"); - - ///Returns a set of all available website data types. - // ignore: non_constant_identifier_names - static final Set ALL = [ - WebsiteDataType.WKWebsiteDataTypeFetchCache, - WebsiteDataType.WKWebsiteDataTypeDiskCache, - WebsiteDataType.WKWebsiteDataTypeMemoryCache, - WebsiteDataType.WKWebsiteDataTypeOfflineWebApplicationCache, - WebsiteDataType.WKWebsiteDataTypeCookies, - WebsiteDataType.WKWebsiteDataTypeSessionStorage, - WebsiteDataType.WKWebsiteDataTypeLocalStorage, - WebsiteDataType.WKWebsiteDataTypeWebSQLDatabases, - WebsiteDataType.WKWebsiteDataTypeIndexedDBDatabases, - WebsiteDataType.WKWebsiteDataTypeServiceWorkerRegistrations - ].toSet(); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents a website data type. -/// -///**NOTE**: available on iOS 9.0+. -/// -///Use [WebsiteDataType] instead. -@Deprecated("Use WebsiteDataType instead") -class IOSWKWebsiteDataType { - final String _value; - - const IOSWKWebsiteDataType._internal(this._value); - - static final Set values = [ - IOSWKWebsiteDataType.WKWebsiteDataTypeFetchCache, - IOSWKWebsiteDataType.WKWebsiteDataTypeDiskCache, - IOSWKWebsiteDataType.WKWebsiteDataTypeMemoryCache, - IOSWKWebsiteDataType.WKWebsiteDataTypeOfflineWebApplicationCache, - IOSWKWebsiteDataType.WKWebsiteDataTypeCookies, - IOSWKWebsiteDataType.WKWebsiteDataTypeSessionStorage, - IOSWKWebsiteDataType.WKWebsiteDataTypeLocalStorage, - IOSWKWebsiteDataType.WKWebsiteDataTypeWebSQLDatabases, - IOSWKWebsiteDataType.WKWebsiteDataTypeIndexedDBDatabases, - IOSWKWebsiteDataType.WKWebsiteDataTypeServiceWorkerRegistrations, - ].toSet(); - - static IOSWKWebsiteDataType? fromValue(String? value) { - if (value != null) { - try { - return IOSWKWebsiteDataType.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - String toValue() => _value; - - @override - String toString() => _value; - - ///On-disk Fetch caches. - /// - ///**NOTE**: available on iOS 11.3+. - static const WKWebsiteDataTypeFetchCache = - const IOSWKWebsiteDataType._internal("WKWebsiteDataTypeFetchCache"); - - ///On-disk caches. - static const WKWebsiteDataTypeDiskCache = - const IOSWKWebsiteDataType._internal("WKWebsiteDataTypeDiskCache"); - - ///In-memory caches. - static const WKWebsiteDataTypeMemoryCache = - const IOSWKWebsiteDataType._internal("WKWebsiteDataTypeMemoryCache"); - - ///HTML offline web application caches. - static const WKWebsiteDataTypeOfflineWebApplicationCache = - const IOSWKWebsiteDataType._internal( - "WKWebsiteDataTypeOfflineWebApplicationCache"); - - ///Cookies. - static const WKWebsiteDataTypeCookies = - const IOSWKWebsiteDataType._internal("WKWebsiteDataTypeCookies"); - - ///HTML session storage. - static const WKWebsiteDataTypeSessionStorage = - const IOSWKWebsiteDataType._internal("WKWebsiteDataTypeSessionStorage"); - - ///HTML local storage. - static const WKWebsiteDataTypeLocalStorage = - const IOSWKWebsiteDataType._internal("WKWebsiteDataTypeLocalStorage"); - - ///WebSQL databases. - static const WKWebsiteDataTypeWebSQLDatabases = - const IOSWKWebsiteDataType._internal("WKWebsiteDataTypeWebSQLDatabases"); - - ///IndexedDB databases. - static const WKWebsiteDataTypeIndexedDBDatabases = - const IOSWKWebsiteDataType._internal( - "WKWebsiteDataTypeIndexedDBDatabases"); - - ///Service worker registrations. - /// - ///**NOTE**: available on iOS 11.3+. - static const WKWebsiteDataTypeServiceWorkerRegistrations = - const IOSWKWebsiteDataType._internal( - "WKWebsiteDataTypeServiceWorkerRegistrations"); - - ///Returns a set of all available website data types. - // ignore: non_constant_identifier_names - static final Set ALL = [ - IOSWKWebsiteDataType.WKWebsiteDataTypeFetchCache, - IOSWKWebsiteDataType.WKWebsiteDataTypeDiskCache, - IOSWKWebsiteDataType.WKWebsiteDataTypeMemoryCache, - IOSWKWebsiteDataType.WKWebsiteDataTypeOfflineWebApplicationCache, - IOSWKWebsiteDataType.WKWebsiteDataTypeCookies, - IOSWKWebsiteDataType.WKWebsiteDataTypeSessionStorage, - IOSWKWebsiteDataType.WKWebsiteDataTypeLocalStorage, - IOSWKWebsiteDataType.WKWebsiteDataTypeWebSQLDatabases, - IOSWKWebsiteDataType.WKWebsiteDataTypeIndexedDBDatabases, - IOSWKWebsiteDataType.WKWebsiteDataTypeServiceWorkerRegistrations - ].toSet(); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents website data, grouped by domain name using the public suffix list. -/// -///**NOTE**: available on iOS 9.0+. -class WebsiteDataRecord { - ///The display name for the data record. This is usually the domain name. - String? displayName; - - ///The various types of website data that exist for this data record. - Set? dataTypes; - - WebsiteDataRecord({this.displayName, this.dataTypes}); - - Map toMap() { - List dataTypesString = []; - if (dataTypes != null) { - for (var dataType in dataTypes!) { - dataTypesString.add(dataType.toValue()); - } - } - - return {"displayName": displayName, "dataTypes": dataTypesString}; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents website data, grouped by domain name using the public suffix list. -/// -///**NOTE**: available on iOS 9.0+. -/// -///Use [WebsiteDataRecord] instead. -@Deprecated("Use WebsiteDataRecord instead") -class IOSWKWebsiteDataRecord { - ///The display name for the data record. This is usually the domain name. - String? displayName; - - ///The various types of website data that exist for this data record. - Set? dataTypes; - - IOSWKWebsiteDataRecord({this.displayName, this.dataTypes}); - - Map toMap() { - List dataTypesString = []; - if (dataTypes != null) { - for (var dataType in dataTypes!) { - dataTypesString.add(dataType.toValue()); - } - } - - return {"displayName": displayName, "dataTypes": dataTypesString}; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class representing the [InAppWebViewHitTestResult] type. -class InAppWebViewHitTestResultType { - final int _value; - - const InAppWebViewHitTestResultType._internal(this._value); - - static final Set values = [ - InAppWebViewHitTestResultType.UNKNOWN_TYPE, - InAppWebViewHitTestResultType.PHONE_TYPE, - InAppWebViewHitTestResultType.GEO_TYPE, - InAppWebViewHitTestResultType.EMAIL_TYPE, - InAppWebViewHitTestResultType.IMAGE_TYPE, - InAppWebViewHitTestResultType.SRC_ANCHOR_TYPE, - InAppWebViewHitTestResultType.SRC_IMAGE_ANCHOR_TYPE, - InAppWebViewHitTestResultType.EDIT_TEXT_TYPE, - ].toSet(); - - static InAppWebViewHitTestResultType? fromValue(int? value) { - if (value != null) { - try { - return InAppWebViewHitTestResultType.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 2: - return "PHONE_TYPE"; - case 3: - return "GEO_TYPE"; - case 4: - return "EMAIL_TYPE"; - case 5: - return "IMAGE_TYPE"; - case 7: - return "SRC_ANCHOR_TYPE"; - case 8: - return "SRC_IMAGE_ANCHOR_TYPE"; - case 9: - return "EDIT_TEXT_TYPE"; - case 0: - default: - return "UNKNOWN_TYPE"; - } - } - - ///Default [InAppWebViewHitTestResult], where the target is unknown. - static const UNKNOWN_TYPE = const InAppWebViewHitTestResultType._internal(0); - - ///[InAppWebViewHitTestResult] for hitting a phone number. - static const PHONE_TYPE = const InAppWebViewHitTestResultType._internal(2); - - ///[InAppWebViewHitTestResult] for hitting a map address. - static const GEO_TYPE = const InAppWebViewHitTestResultType._internal(3); - - ///[InAppWebViewHitTestResult] for hitting an email address. - static const EMAIL_TYPE = const InAppWebViewHitTestResultType._internal(4); - - ///[InAppWebViewHitTestResult] for hitting an HTML::img tag. - static const IMAGE_TYPE = const InAppWebViewHitTestResultType._internal(5); - - ///[InAppWebViewHitTestResult] for hitting a HTML::a tag with src=http. - static const SRC_ANCHOR_TYPE = - const InAppWebViewHitTestResultType._internal(7); - - ///[InAppWebViewHitTestResult] for hitting a HTML::a tag with src=http + HTML::img. - static const SRC_IMAGE_ANCHOR_TYPE = - const InAppWebViewHitTestResultType._internal(8); - - ///[InAppWebViewHitTestResult] for hitting an edit text area. - static const EDIT_TEXT_TYPE = - const InAppWebViewHitTestResultType._internal(9); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents the hit result for hitting an HTML elements. -class InAppWebViewHitTestResult { - ///The type of the hit test result. - InAppWebViewHitTestResultType? type; - - ///Additional type-dependant information about the result. - String? extra; - - InAppWebViewHitTestResult({this.type, this.extra}); - - Map toMap() { - return {"type": type?.toValue(), "extra": extra}; - } - - static InAppWebViewHitTestResult? fromMap(Map? map) { - if (map == null) { - return null; - } - - return InAppWebViewHitTestResult( - type: InAppWebViewHitTestResultType.fromValue(map["type"]), - extra: map["extra"]); - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents the action to take used by the [WebView.onRenderProcessUnresponsive] and [WebView.onRenderProcessResponsive] event -///to terminate the Android [WebViewRenderProcess](https://developer.android.com/reference/android/webkit/WebViewRenderProcess). -class WebViewRenderProcessAction { - final int _value; - - const WebViewRenderProcessAction._internal(this._value); - - int toValue() => _value; - - ///Cause this renderer to terminate. - static const TERMINATE = const WebViewRenderProcessAction._internal(0); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; - - Map toMap() { - return {"action": _value}; - } -} - -///Class that provides more specific information about why the render process exited. -///It is used by the [WebView.onRenderProcessGone] event. -class RenderProcessGoneDetail { - ///Indicates whether the render process was observed to crash, or whether it was killed by the system. - /// - ///If the render process was killed, this is most likely caused by the system being low on memory. - bool didCrash; - - /// Returns the renderer priority that was set at the time that the renderer exited. This may be greater than the priority that - /// any individual [WebView] requested using []. - RendererPriority? rendererPriorityAtExit; - - RenderProcessGoneDetail( - {required this.didCrash, this.rendererPriorityAtExit}); - - static RenderProcessGoneDetail? fromMap(Map? map) { - if (map == null) { - return null; - } - return RenderProcessGoneDetail( - didCrash: map["didCrash"], - rendererPriorityAtExit: - RendererPriority.fromValue(map["rendererPriorityAtExit"]), - ); - } - - Map toMap() { - return { - "didCrash": didCrash, - "rendererPriorityAtExit": rendererPriorityAtExit?.toValue() - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class used by [RendererPriorityPolicy] class. -class RendererPriority { - final int _value; - - const RendererPriority._internal(this._value); - - static final Set values = [ - RendererPriority.RENDERER_PRIORITY_WAIVED, - RendererPriority.RENDERER_PRIORITY_BOUND, - RendererPriority.RENDERER_PRIORITY_IMPORTANT, - ].toSet(); - - static RendererPriority? fromValue(int? value) { - if (value != null) { - try { - return RendererPriority.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 0: - return "RENDERER_PRIORITY_WAIVED"; - case 1: - return "RENDERER_PRIORITY_BOUND"; - case 2: - default: - return "RENDERER_PRIORITY_IMPORTANT"; - } - } - - ///The renderer associated with this WebView is bound with Android `Context#BIND_WAIVE_PRIORITY`. - ///At this priority level WebView renderers will be strong targets for out of memory killing. - static const RENDERER_PRIORITY_WAIVED = const RendererPriority._internal(0); - - ///The renderer associated with this WebView is bound with the default priority for services. - static const RENDERER_PRIORITY_BOUND = const RendererPriority._internal(1); - - ///The renderer associated with this WebView is bound with Android `Context#BIND_IMPORTANT`. - static const RENDERER_PRIORITY_IMPORTANT = - const RendererPriority._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents the priority policy will be used to determine whether an out of process renderer should be considered to be a target for OOM killing. -///When a WebView is destroyed it will cease to be considerered when calculating the renderer priority. -///Once no WebViews remain associated with the renderer, the priority of the renderer will be reduced to [RendererPriority.RENDERER_PRIORITY_WAIVED]. -///The default policy is to set the priority to [RendererPriority.RENDERER_PRIORITY_IMPORTANT] regardless of visibility, -///and this should not be changed unless the caller also handles renderer crashes with [WebView.onRenderProcessGone]. -///Any other setting will result in WebView renderers being killed by the system more aggressively than the application. -class RendererPriorityPolicy { - ///The minimum priority at which this WebView desires the renderer process to be bound. - RendererPriority? rendererRequestedPriority; - - ///If true, this flag specifies that when this WebView is not visible, it will be treated as if it had requested a priority of [RendererPriority.RENDERER_PRIORITY_WAIVED]. - bool waivedWhenNotVisible; - - RendererPriorityPolicy( - {required this.rendererRequestedPriority, - required this.waivedWhenNotVisible}); - - Map toMap() { - return { - "rendererRequestedPriority": rendererRequestedPriority?.toValue(), - "waivedWhenNotVisible": waivedWhenNotVisible - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } - - static RendererPriorityPolicy? fromMap(Map? map) { - return map != null - ? RendererPriorityPolicy( - rendererRequestedPriority: - RendererPriority.fromValue(map["rendererRequestedPriority"]), - waivedWhenNotVisible: map["waivedWhenNotVisible"]) - : null; - } -} - -///Class that represents the action to take used by the [WebView.onFormResubmission] event. -class FormResubmissionAction { - final int _value; - - const FormResubmissionAction._internal(this._value); - - int toValue() => _value; - - ///Resend data - static const RESEND = const FormResubmissionAction._internal(0); - - ///Don't resend data - static const DONT_RESEND = const FormResubmissionAction._internal(1); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; - - Map toMap() { - return {"action": _value}; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class used to configure the WebView's over-scroll mode. -///Setting the over-scroll mode of a WebView will have an effect only if the WebView is capable of scrolling. -class OverScrollMode { - final int _value; - - const OverScrollMode._internal(this._value); - - static final Set values = [ - OverScrollMode.OVER_SCROLL_ALWAYS, - OverScrollMode.OVER_SCROLL_IF_CONTENT_SCROLLS, - OverScrollMode.OVER_SCROLL_NEVER, - ].toSet(); - - static OverScrollMode? fromValue(int? value) { - if (value != null) { - try { - return OverScrollMode.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "OVER_SCROLL_IF_CONTENT_SCROLLS"; - case 2: - return "OVER_SCROLL_NEVER"; - case 0: - default: - return "OVER_SCROLL_ALWAYS"; - } - } - - ///Always allow a user to over-scroll this view, provided it is a view that can scroll. - static const OVER_SCROLL_ALWAYS = const OverScrollMode._internal(0); - - ///Allow a user to over-scroll this view only if the content is large enough to meaningfully scroll, provided it is a view that can scroll. - static const OVER_SCROLL_IF_CONTENT_SCROLLS = - const OverScrollMode._internal(1); - - ///Never allow a user to over-scroll this view. - static const OVER_SCROLL_NEVER = const OverScrollMode._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///An Android-specific class used to configure the WebView's over-scroll mode. -///Setting the over-scroll mode of a WebView will have an effect only if the WebView is capable of scrolling. -///Use [OverScrollMode] instead. -@Deprecated("Use OverScrollMode instead") -class AndroidOverScrollMode { - final int _value; - - const AndroidOverScrollMode._internal(this._value); - - static final Set values = [ - AndroidOverScrollMode.OVER_SCROLL_ALWAYS, - AndroidOverScrollMode.OVER_SCROLL_IF_CONTENT_SCROLLS, - AndroidOverScrollMode.OVER_SCROLL_NEVER, - ].toSet(); - - static AndroidOverScrollMode? fromValue(int? value) { - if (value != null) { - try { - return AndroidOverScrollMode.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "OVER_SCROLL_IF_CONTENT_SCROLLS"; - case 2: - return "OVER_SCROLL_NEVER"; - case 0: - default: - return "OVER_SCROLL_ALWAYS"; - } - } - - ///Always allow a user to over-scroll this view, provided it is a view that can scroll. - static const OVER_SCROLL_ALWAYS = const AndroidOverScrollMode._internal(0); - - ///Allow a user to over-scroll this view only if the content is large enough to meaningfully scroll, provided it is a view that can scroll. - static const OVER_SCROLL_IF_CONTENT_SCROLLS = - const AndroidOverScrollMode._internal(1); - - ///Never allow a user to over-scroll this view. - static const OVER_SCROLL_NEVER = const AndroidOverScrollMode._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class used to configure the style of the scrollbars. -///The scrollbars can be overlaid or inset. -///When inset, they add to the padding of the view. And the scrollbars can be drawn inside the padding area or on the edge of the view. -///For example, if a view has a background drawable and you want to draw the scrollbars inside the padding specified by the drawable, -///you can use [ScrollBarStyle.SCROLLBARS_INSIDE_OVERLAY] or [ScrollBarStyle.SCROLLBARS_INSIDE_INSET]. -///If you want them to appear at the edge of the view, ignoring the padding, -///then you can use [ScrollBarStyle.SCROLLBARS_OUTSIDE_OVERLAY] or [ScrollBarStyle.SCROLLBARS_OUTSIDE_INSET]. -class ScrollBarStyle { - final int _value; - - const ScrollBarStyle._internal(this._value); - - static final Set values = [ - ScrollBarStyle.SCROLLBARS_INSIDE_OVERLAY, - ScrollBarStyle.SCROLLBARS_INSIDE_INSET, - ScrollBarStyle.SCROLLBARS_OUTSIDE_OVERLAY, - ScrollBarStyle.SCROLLBARS_OUTSIDE_INSET, - ].toSet(); - - static ScrollBarStyle? fromValue(int? value) { - if (value != null) { - try { - return ScrollBarStyle.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 16777216: - return "SCROLLBARS_INSIDE_INSET"; - case 33554432: - return "SCROLLBARS_OUTSIDE_OVERLAY"; - case 50331648: - return "SCROLLBARS_OUTSIDE_INSET"; - case 0: - default: - return "SCROLLBARS_INSIDE_OVERLAY"; - } - } - - ///The scrollbar style to display the scrollbars inside the content area, without increasing the padding. - ///The scrollbars will be overlaid with translucency on the view's content. - static const SCROLLBARS_INSIDE_OVERLAY = const ScrollBarStyle._internal(0); - - ///The scrollbar style to display the scrollbars inside the padded area, increasing the padding of the view. - ///The scrollbars will not overlap the content area of the view. - static const SCROLLBARS_INSIDE_INSET = - const ScrollBarStyle._internal(16777216); - - ///The scrollbar style to display the scrollbars at the edge of the view, without increasing the padding. - ///The scrollbars will be overlaid with translucency. - static const SCROLLBARS_OUTSIDE_OVERLAY = - const ScrollBarStyle._internal(33554432); - - ///The scrollbar style to display the scrollbars at the edge of the view, increasing the padding of the view. - ///The scrollbars will only overlap the background, if any. - static const SCROLLBARS_OUTSIDE_INSET = - const ScrollBarStyle._internal(50331648); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///An Android-specific class used to configure the style of the scrollbars. -///The scrollbars can be overlaid or inset. -///When inset, they add to the padding of the view. And the scrollbars can be drawn inside the padding area or on the edge of the view. -///For example, if a view has a background drawable and you want to draw the scrollbars inside the padding specified by the drawable, -///you can use [AndroidScrollBarStyle.SCROLLBARS_INSIDE_OVERLAY] or [AndroidScrollBarStyle.SCROLLBARS_INSIDE_INSET]. -///If you want them to appear at the edge of the view, ignoring the padding, -///then you can use [AndroidScrollBarStyle.SCROLLBARS_OUTSIDE_OVERLAY] or [AndroidScrollBarStyle.SCROLLBARS_OUTSIDE_INSET]. -/// -///Use [ScrollBarStyle] instead. -@Deprecated("Use ScrollBarStyle instead") -class AndroidScrollBarStyle { - final int _value; - - const AndroidScrollBarStyle._internal(this._value); - - static final Set values = [ - AndroidScrollBarStyle.SCROLLBARS_INSIDE_OVERLAY, - AndroidScrollBarStyle.SCROLLBARS_INSIDE_INSET, - AndroidScrollBarStyle.SCROLLBARS_OUTSIDE_OVERLAY, - AndroidScrollBarStyle.SCROLLBARS_OUTSIDE_INSET, - ].toSet(); - - static AndroidScrollBarStyle? fromValue(int? value) { - if (value != null) { - try { - return AndroidScrollBarStyle.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 16777216: - return "SCROLLBARS_INSIDE_INSET"; - case 33554432: - return "SCROLLBARS_OUTSIDE_OVERLAY"; - case 50331648: - return "SCROLLBARS_OUTSIDE_INSET"; - case 0: - default: - return "SCROLLBARS_INSIDE_OVERLAY"; - } - } - - ///The scrollbar style to display the scrollbars inside the content area, without increasing the padding. - ///The scrollbars will be overlaid with translucency on the view's content. - static const SCROLLBARS_INSIDE_OVERLAY = - const AndroidScrollBarStyle._internal(0); - - ///The scrollbar style to display the scrollbars inside the padded area, increasing the padding of the view. - ///The scrollbars will not overlap the content area of the view. - static const SCROLLBARS_INSIDE_INSET = - const AndroidScrollBarStyle._internal(16777216); - - ///The scrollbar style to display the scrollbars at the edge of the view, without increasing the padding. - ///The scrollbars will be overlaid with translucency. - static const SCROLLBARS_OUTSIDE_OVERLAY = - const AndroidScrollBarStyle._internal(33554432); - - ///The scrollbar style to display the scrollbars at the edge of the view, increasing the padding of the view. - ///The scrollbars will only overlap the background, if any. - static const SCROLLBARS_OUTSIDE_INSET = - const AndroidScrollBarStyle._internal(50331648); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class used to configure the position of the vertical scroll bar. -class VerticalScrollbarPosition { - final int _value; - - const VerticalScrollbarPosition._internal(this._value); - - static final Set values = [ - VerticalScrollbarPosition.SCROLLBAR_POSITION_DEFAULT, - VerticalScrollbarPosition.SCROLLBAR_POSITION_LEFT, - VerticalScrollbarPosition.SCROLLBAR_POSITION_RIGHT, - ].toSet(); - - static VerticalScrollbarPosition? fromValue(int? value) { - if (value != null) { - try { - return VerticalScrollbarPosition.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "SCROLLBAR_POSITION_LEFT"; - case 2: - return "SCROLLBAR_POSITION_RIGHT"; - case 0: - default: - return "SCROLLBAR_POSITION_DEFAULT"; - } - } - - ///Position the scroll bar at the default position as determined by the system. - static const SCROLLBAR_POSITION_DEFAULT = - const VerticalScrollbarPosition._internal(0); - - ///Position the scroll bar along the left edge. - static const SCROLLBAR_POSITION_LEFT = - const VerticalScrollbarPosition._internal(1); - - ///Position the scroll bar along the right edge. - static const SCROLLBAR_POSITION_RIGHT = - const VerticalScrollbarPosition._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///An Android-specific class used to configure the position of the vertical scroll bar. -///Use [VerticalScrollbarPosition] instead. -@Deprecated("Use VerticalScrollbarPosition instead") -class AndroidVerticalScrollbarPosition { - final int _value; - - const AndroidVerticalScrollbarPosition._internal(this._value); - - static final Set values = [ - AndroidVerticalScrollbarPosition.SCROLLBAR_POSITION_DEFAULT, - AndroidVerticalScrollbarPosition.SCROLLBAR_POSITION_LEFT, - AndroidVerticalScrollbarPosition.SCROLLBAR_POSITION_RIGHT, - ].toSet(); - - static AndroidVerticalScrollbarPosition? fromValue(int? value) { - if (value != null) { - try { - return AndroidVerticalScrollbarPosition.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "SCROLLBAR_POSITION_LEFT"; - case 2: - return "SCROLLBAR_POSITION_RIGHT"; - case 0: - default: - return "SCROLLBAR_POSITION_DEFAULT"; - } - } - - ///Position the scroll bar at the default position as determined by the system. - static const SCROLLBAR_POSITION_DEFAULT = - const AndroidVerticalScrollbarPosition._internal(0); - - ///Position the scroll bar along the left edge. - static const SCROLLBAR_POSITION_LEFT = - const AndroidVerticalScrollbarPosition._internal(1); - - ///Position the scroll bar along the right edge. - static const SCROLLBAR_POSITION_RIGHT = - const AndroidVerticalScrollbarPosition._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents a WebView package info. -class WebViewPackageInfo { - ///The version name of this WebView package. - String? versionName; - - ///The name of this WebView package. - String? packageName; - - WebViewPackageInfo({this.versionName, this.packageName}); - - static WebViewPackageInfo? fromMap(Map? map) { - return map != null - ? WebViewPackageInfo( - versionName: map["versionName"], packageName: map["packageName"]) - : null; - } - - Map toMap() { - return {"versionName": versionName, "packageName": packageName}; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents an Android WebView package info. -///Use [WebViewPackageInfo] instead. -@Deprecated("Use WebViewPackageInfo instead") -class AndroidWebViewPackageInfo { - ///The version name of this WebView package. - String? versionName; - - ///The name of this WebView package. - String? packageName; - - AndroidWebViewPackageInfo({this.versionName, this.packageName}); - - static AndroidWebViewPackageInfo? fromMap(Map? map) { - return map != null - ? AndroidWebViewPackageInfo( - versionName: map["versionName"], packageName: map["packageName"]) - : null; - } - - Map toMap() { - return {"versionName": versionName, "packageName": packageName}; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents the result used by the [InAppWebViewController.requestFocusNodeHref] method. -class RequestFocusNodeHrefResult { - ///The anchor's href attribute. - Uri? url; - - ///The anchor's text. - String? title; - - ///The image's src attribute. - String? src; - - RequestFocusNodeHrefResult({this.url, this.title, this.src}); - - Map toMap() { - return {"url": url?.toString(), "title": title, "src": src}; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents the result used by the [InAppWebViewController.requestImageRef] method. -class RequestImageRefResult { - ///The image's url. - Uri? url; - - RequestImageRefResult({this.url}); - - Map toMap() { - return { - "url": url?.toString(), - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents a `` HTML tag. It is used by the [InAppWebViewController.getMetaTags] method. -class MetaTag { - ///The meta tag name value. - String? name; - - ///The meta tag content value. - String? content; - - ///The meta tag attributes list. - List? attrs; - - MetaTag({this.name, this.content, this.attrs}); - - Map toMap() { - return {"name": name, "content": content, "attrs": attrs}; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents an attribute of a `` HTML tag. It is used by the [MetaTag] class. -class MetaTagAttribute { - ///The attribute name. - String? name; - - ///The attribute value. - String? value; - - MetaTagAttribute({this.name, this.value}); - - Map toMap() { - return { - "name": name, - "value": value, - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents the type of Web Storage: `localStorage` or `sessionStorage`. -///Used by the [Storage] class. -class WebStorageType { - final String _value; - - const WebStorageType._internal(this._value); - - static final Set values = [ - WebStorageType.LOCAL_STORAGE, - WebStorageType.SESSION_STORAGE, - ].toSet(); - - static WebStorageType? fromValue(String? value) { - if (value != null) { - try { - return WebStorageType.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - String toValue() => _value; - - @override - String toString() => _value; - - ///`window.localStorage`: same as [SESSION_STORAGE], but persists even when the browser is closed and reopened. - static const LOCAL_STORAGE = const WebStorageType._internal("localStorage"); - - ///`window.sessionStorage`: maintains a separate storage area for each given origin that's available for the duration - ///of the page session (as long as the browser is open, including page reloads and restores). - static const SESSION_STORAGE = - const WebStorageType._internal("sessionStorage"); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents the same site policy of a cookie. Used by the [Cookie] class. -class HTTPCookieSameSitePolicy { - final String _value; - - const HTTPCookieSameSitePolicy._internal(this._value); - - static final Set values = [ - HTTPCookieSameSitePolicy.LAX, - HTTPCookieSameSitePolicy.STRICT, - HTTPCookieSameSitePolicy.NONE, - ].toSet(); - - static HTTPCookieSameSitePolicy? fromValue(String? value) { - if (value != null) { - try { - return HTTPCookieSameSitePolicy.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - String toValue() => _value; - - @override - String toString() => _value; - - ///SameSite=Lax; - /// - ///Cookies are allowed to be sent with top-level navigations and will be sent along with GET - ///request initiated by third party website. This is the default value in modern browsers. - static const LAX = const HTTPCookieSameSitePolicy._internal("Lax"); - - ///SameSite=Strict; - /// - ///Cookies will only be sent in a first-party context and not be sent along with requests initiated by third party websites. - static const STRICT = const HTTPCookieSameSitePolicy._internal("Strict"); - - ///SameSite=None; - /// - ///Cookies will be sent in all contexts, i.e sending cross-origin is allowed. - ///`None` requires the `Secure` attribute in latest browser versions. - static const NONE = const HTTPCookieSameSitePolicy._internal("None"); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents the SSL Primary error associated to the server SSL certificate. -///Used by the [ServerTrustChallenge] class. -class SslErrorType { - final int _value; - - const SslErrorType._internal(this._value); - - static final Set values = [ - SslErrorType.SSL_NOTYETVALID, - SslErrorType.SSL_EXPIRED, - SslErrorType.SSL_IDMISMATCH, - SslErrorType.SSL_UNTRUSTED, - SslErrorType.SSL_DATE_INVALID, - SslErrorType.SSL_INVALID, - SslErrorType.INVALID, - SslErrorType.DENY, - SslErrorType.UNSPECIFIED, - SslErrorType.RECOVERABLE_TRUST_FAILURE, - SslErrorType.FATAL_TRUST_FAILURE, - SslErrorType.OTHER_ERROR, - ].toSet(); - - static final Set _androidValues = [ - SslErrorType.SSL_NOTYETVALID, - SslErrorType.SSL_EXPIRED, - SslErrorType.SSL_IDMISMATCH, - SslErrorType.SSL_UNTRUSTED, - SslErrorType.SSL_DATE_INVALID, - SslErrorType.SSL_INVALID, - ].toSet(); - - static final Set _appleValues = [ - SslErrorType.INVALID, - SslErrorType.DENY, - SslErrorType.UNSPECIFIED, - SslErrorType.RECOVERABLE_TRUST_FAILURE, - SslErrorType.FATAL_TRUST_FAILURE, - SslErrorType.OTHER_ERROR, - ].toSet(); - - static SslErrorType? fromValue(int? value) { - if (value != null) { - try { - Set valueList = [].toSet(); - if (defaultTargetPlatform == TargetPlatform.android) { - valueList = SslErrorType._androidValues; - } else if (defaultTargetPlatform == TargetPlatform.iOS || - defaultTargetPlatform == TargetPlatform.macOS) { - valueList = SslErrorType._appleValues; - } - return valueList.firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - if (defaultTargetPlatform == TargetPlatform.android) { - switch (_value) { - case 1: - return "SSL_EXPIRED"; - case 2: - return "SSL_IDMISMATCH"; - case 3: - return "SSL_UNTRUSTED"; - case 4: - return "SSL_DATE_INVALID"; - case 5: - return "SSL_INVALID"; - case 0: - default: - return "SSL_NOTYETVALID"; - } - } else if (defaultTargetPlatform == TargetPlatform.iOS || - defaultTargetPlatform == TargetPlatform.macOS) { - switch (_value) { - case 3: - return "DENY"; - case 4: - return "UNSPECIFIED"; - case 5: - return "RECOVERABLE_TRUST_FAILURE"; - case 6: - return "FATAL_TRUST_FAILURE"; - case 7: - return "OTHER_ERROR"; - case 0: - default: - return "INVALID"; - } - } - return ""; - } - - ///The certificate is not yet valid - /// - ///**NOTE**: available only on Android - static const SSL_NOTYETVALID = const SslErrorType._internal(0); - - ///The certificate has expired - /// - ///**NOTE**: available only on Android - static const SSL_EXPIRED = const SslErrorType._internal(1); - - ///Hostname mismatch - /// - ///**NOTE**: available only on Android - static const SSL_IDMISMATCH = const SslErrorType._internal(2); - - ///The certificate authority is not trusted - /// - ///**NOTE**: available only on Android - static const SSL_UNTRUSTED = const SslErrorType._internal(3); - - ///The date of the certificate is invalid - /// - ///**NOTE**: available only on Android - static const SSL_DATE_INVALID = const SslErrorType._internal(4); - - ///A generic error occurred - /// - ///**NOTE**: available only on Android - static const SSL_INVALID = const SslErrorType._internal(5); - - ///Indicates an invalid setting or result. - /// - ///**NOTE**: available only on iOS - static const INVALID = const SslErrorType._internal(0); - - ///Indicates a user-configured deny; do not proceed. - /// - ///**NOTE**: available only on iOS - static const DENY = const SslErrorType._internal(3); - - ///Indicates the evaluation succeeded and the certificate is implicitly trusted, but user intent was not explicitly specified. - /// - ///**NOTE**: available only on iOS - static const UNSPECIFIED = const SslErrorType._internal(4); - - ///Indicates a trust policy failure which can be overridden by the user. - /// - ///**NOTE**: available only on iOS - static const RECOVERABLE_TRUST_FAILURE = const SslErrorType._internal(5); - - ///Indicates a trust failure which cannot be overridden by the user. - /// - ///**NOTE**: available only on iOS - static const FATAL_TRUST_FAILURE = const SslErrorType._internal(6); - - ///Indicates a failure other than that of trust evaluation. - /// - ///**NOTE**: available only on iOS - static const OTHER_ERROR = const SslErrorType._internal(7); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents the Android-specific primary error associated to the server SSL certificate. -///Used by the [ServerTrustChallenge] class. -///Use [SslErrorType] instead. -@Deprecated("Use SslErrorType instead") -class AndroidSslError { - final int _value; - - const AndroidSslError._internal(this._value); - - static final Set values = [ - AndroidSslError.SSL_NOTYETVALID, - AndroidSslError.SSL_EXPIRED, - AndroidSslError.SSL_IDMISMATCH, - AndroidSslError.SSL_UNTRUSTED, - AndroidSslError.SSL_DATE_INVALID, - AndroidSslError.SSL_INVALID, - ].toSet(); - - static AndroidSslError? fromValue(int? value) { - if (value != null) { - try { - return AndroidSslError.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "SSL_EXPIRED"; - case 2: - return "SSL_IDMISMATCH"; - case 3: - return "SSL_UNTRUSTED"; - case 4: - return "SSL_DATE_INVALID"; - case 5: - return "SSL_INVALID"; - case 0: - default: - return "SSL_NOTYETVALID"; - } - } - - ///The certificate is not yet valid - static const SSL_NOTYETVALID = const AndroidSslError._internal(0); - - ///The certificate has expired - static const SSL_EXPIRED = const AndroidSslError._internal(1); - - ///Hostname mismatch - static const SSL_IDMISMATCH = const AndroidSslError._internal(2); - - ///The certificate authority is not trusted - static const SSL_UNTRUSTED = const AndroidSslError._internal(3); - - ///The date of the certificate is invalid - static const SSL_DATE_INVALID = const AndroidSslError._internal(4); - - ///A generic error occurred - static const SSL_INVALID = const AndroidSslError._internal(5); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents the iOS-specific primary error associated to the server SSL certificate. -///Used by the [ServerTrustChallenge] class. -///Use [SslErrorType] instead. -@Deprecated("Use SslErrorType instead") -class IOSSslError { - final int _value; - - const IOSSslError._internal(this._value); - - static final Set values = [ - IOSSslError.INVALID, - IOSSslError.DENY, - IOSSslError.UNSPECIFIED, - IOSSslError.RECOVERABLE_TRUST_FAILURE, - IOSSslError.FATAL_TRUST_FAILURE, - IOSSslError.OTHER_ERROR, - ].toSet(); - - static IOSSslError? fromValue(int? value) { - if (value != null) { - try { - return IOSSslError.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 3: - return "DENY"; - case 4: - return "UNSPECIFIED"; - case 5: - return "RECOVERABLE_TRUST_FAILURE"; - case 6: - return "FATAL_TRUST_FAILURE"; - case 7: - return "OTHER_ERROR"; - case 0: - default: - return "INVALID"; - } - } - - ///Indicates an invalid setting or result. - static const INVALID = const IOSSslError._internal(0); - - ///Indicates a user-configured deny; do not proceed. - static const DENY = const IOSSslError._internal(3); - - ///Indicates the evaluation succeeded and the certificate is implicitly trusted, but user intent was not explicitly specified. - static const UNSPECIFIED = const IOSSslError._internal(4); - - ///Indicates a trust policy failure which can be overridden by the user. - static const RECOVERABLE_TRUST_FAILURE = const IOSSslError._internal(5); - - ///Indicates a trust failure which cannot be overridden by the user. - static const FATAL_TRUST_FAILURE = const IOSSslError._internal(6); - - ///Indicates a failure other than that of trust evaluation. - static const OTHER_ERROR = const IOSSslError._internal(7); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class used to configure how safe area insets are added to the adjusted content inset. -/// -///**NOTE**: available on iOS 11.0+. -class ScrollViewContentInsetAdjustmentBehavior { - final int _value; - - const ScrollViewContentInsetAdjustmentBehavior._internal(this._value); - - static final Set values = [ - ScrollViewContentInsetAdjustmentBehavior.AUTOMATIC, - ScrollViewContentInsetAdjustmentBehavior.SCROLLABLE_AXES, - ScrollViewContentInsetAdjustmentBehavior.NEVER, - ScrollViewContentInsetAdjustmentBehavior.ALWAYS, - ].toSet(); - - static ScrollViewContentInsetAdjustmentBehavior? fromValue(int? value) { - if (value != null) { - try { - return ScrollViewContentInsetAdjustmentBehavior.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "SCROLLABLE_AXES"; - case 2: - return "NEVER"; - case 3: - return "ALWAYS"; - case 0: - default: - return "AUTOMATIC"; - } - } - - ///Automatically adjust the scroll view insets. - static const AUTOMATIC = - const ScrollViewContentInsetAdjustmentBehavior._internal(0); - - ///Adjust the insets only in the scrollable directions. - static const SCROLLABLE_AXES = - const ScrollViewContentInsetAdjustmentBehavior._internal(1); - - ///Do not adjust the scroll view insets. - static const NEVER = - const ScrollViewContentInsetAdjustmentBehavior._internal(2); - - ///Always include the safe area insets in the content adjustment. - static const ALWAYS = - const ScrollViewContentInsetAdjustmentBehavior._internal(3); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///An iOS-specific class used to configure how safe area insets are added to the adjusted content inset. -/// -///**NOTE**: available on iOS 11.0+. -/// -///Use [ScrollViewContentInsetAdjustmentBehavior] instead. -@Deprecated("Use ScrollViewContentInsetAdjustmentBehavior instead") -class IOSUIScrollViewContentInsetAdjustmentBehavior { - final int _value; - - const IOSUIScrollViewContentInsetAdjustmentBehavior._internal(this._value); - - static final Set values = [ - IOSUIScrollViewContentInsetAdjustmentBehavior.AUTOMATIC, - IOSUIScrollViewContentInsetAdjustmentBehavior.SCROLLABLE_AXES, - IOSUIScrollViewContentInsetAdjustmentBehavior.NEVER, - IOSUIScrollViewContentInsetAdjustmentBehavior.ALWAYS, - ].toSet(); - - static IOSUIScrollViewContentInsetAdjustmentBehavior? fromValue(int? value) { - if (value != null) { - try { - return IOSUIScrollViewContentInsetAdjustmentBehavior.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "SCROLLABLE_AXES"; - case 2: - return "NEVER"; - case 3: - return "ALWAYS"; - case 0: - default: - return "AUTOMATIC"; - } - } - - ///Automatically adjust the scroll view insets. - static const AUTOMATIC = - const IOSUIScrollViewContentInsetAdjustmentBehavior._internal(0); - - ///Adjust the insets only in the scrollable directions. - static const SCROLLABLE_AXES = - const IOSUIScrollViewContentInsetAdjustmentBehavior._internal(1); - - ///Do not adjust the scroll view insets. - static const NEVER = - const IOSUIScrollViewContentInsetAdjustmentBehavior._internal(2); - - ///Always include the safe area insets in the content adjustment. - static const ALWAYS = - const IOSUIScrollViewContentInsetAdjustmentBehavior._internal(3); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///SSL certificate info (certificate details) class. -class SslCertificate { - ///Name of the entity this certificate is issued by. - SslCertificateDName? issuedBy; - - ///Name of the entity this certificate is issued to. - SslCertificateDName? issuedTo; - - ///Not-after date from the validity period. - DateTime? validNotAfterDate; - - ///Not-before date from the validity period. - DateTime? validNotBeforeDate; - - ///The original source certificate, if available. - X509Certificate? x509Certificate; - - SslCertificate( - {this.issuedBy, - this.issuedTo, - this.validNotAfterDate, - this.validNotBeforeDate, - this.x509Certificate}); - - static SslCertificate? fromMap(Map? map) { - if (map == null) { - return null; - } - - X509Certificate? x509Certificate; - try { - x509Certificate = X509Certificate.fromData(data: map["x509Certificate"]); - } catch (e, stacktrace) { - print(e); - print(stacktrace); - } - - if (defaultTargetPlatform == TargetPlatform.iOS) { - if (x509Certificate != null) { - return SslCertificate( - issuedBy: SslCertificateDName( - CName: x509Certificate.issuer( - dn: ASN1DistinguishedNames.COMMON_NAME) ?? - "", - DName: x509Certificate.issuerDistinguishedName ?? "", - OName: x509Certificate.issuer( - dn: ASN1DistinguishedNames.ORGANIZATION_NAME) ?? - "", - UName: x509Certificate.issuer( - dn: ASN1DistinguishedNames.ORGANIZATIONAL_UNIT_NAME) ?? - ""), - issuedTo: SslCertificateDName( - CName: x509Certificate.subject( - dn: ASN1DistinguishedNames.COMMON_NAME) ?? - "", - DName: x509Certificate.subjectDistinguishedName ?? "", - OName: x509Certificate.subject( - dn: ASN1DistinguishedNames.ORGANIZATION_NAME) ?? - "", - UName: x509Certificate.subject( - dn: ASN1DistinguishedNames.ORGANIZATIONAL_UNIT_NAME) ?? - ""), - validNotAfterDate: x509Certificate.notAfter, - validNotBeforeDate: x509Certificate.notBefore, - x509Certificate: x509Certificate, - ); - } - return null; - } - - return SslCertificate( - issuedBy: - SslCertificateDName.fromMap(map["issuedBy"]?.cast()), - issuedTo: - SslCertificateDName.fromMap(map["issuedTo"]?.cast()), - validNotAfterDate: - DateTime.fromMillisecondsSinceEpoch(map["validNotAfterDate"]), - validNotBeforeDate: - DateTime.fromMillisecondsSinceEpoch(map["validNotBeforeDate"]), - x509Certificate: x509Certificate, - ); - } - - Map toMap() { - return { - "issuedBy": issuedBy?.toMap(), - "issuedTo": issuedTo?.toMap(), - "validNotAfterDate": validNotAfterDate?.millisecondsSinceEpoch, - "validNotBeforeDate": validNotBeforeDate?.millisecondsSinceEpoch, - "x509Certificate": x509Certificate?.toMap(), - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Distinguished name helper class. Used by [SslCertificate]. -class SslCertificateDName { - ///Common-name (CN) component of the name - // ignore: non_constant_identifier_names - String? CName; - - ///Distinguished name (normally includes CN, O, and OU names) - // ignore: non_constant_identifier_names - String? DName; - - ///Organization (O) component of the name - // ignore: non_constant_identifier_names - String? OName; - - ///Organizational Unit (OU) component of the name - // ignore: non_constant_identifier_names - String? UName; - - SslCertificateDName( - // ignore: non_constant_identifier_names - {this.CName = "", - // ignore: non_constant_identifier_names - this.DName = "", - // ignore: non_constant_identifier_names - this.OName = "", - // ignore: non_constant_identifier_names - this.UName = ""}); - - static SslCertificateDName? fromMap(Map? map) { - return map != null - ? SslCertificateDName( - CName: map["CName"] ?? "", - DName: map["DName"] ?? "", - OName: map["OName"] ?? "", - UName: map["UName"] ?? "", - ) - : null; - } - - Map toMap() { - return { - "CName": CName, - "DName": DName, - "OName": OName, - "UName": UName, - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class used by [WebView.onReceivedLoginRequest] event. -class LoginRequest { - ///The account realm used to look up accounts. - String realm; - - ///An optional account. If not `null`, the account should be checked against accounts on the device. - ///If it is a valid account, it should be used to log in the user. This value may be `null`. - String? account; - - ///Authenticator specific arguments used to log in the user. - String args; - - LoginRequest({required this.realm, this.account, required this.args}); - - static LoginRequest? fromMap(Map? map) { - if (map == null) { - return null; - } - return LoginRequest( - realm: map["realm"], - account: map["account"], - args: map["args"], - ); - } - - Map toMap() { - return {"realm": realm, "account": account, "args": args}; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -///Class that represents contains the constants for the times at which to inject script content into a [WebView] used by an [UserScript]. -class UserScriptInjectionTime { - final int _value; - - const UserScriptInjectionTime._internal(this._value); - - static final Set values = [ - UserScriptInjectionTime.AT_DOCUMENT_START, - UserScriptInjectionTime.AT_DOCUMENT_END, - ].toSet(); - - static UserScriptInjectionTime? fromValue(int? value) { - if (value != null) { - try { - return UserScriptInjectionTime.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 1: - return "AT_DOCUMENT_END"; - case 0: - default: - return "AT_DOCUMENT_START"; - } - } - - ///**NOTE for iOS**: A constant to inject the script after the creation of the webpage’s document element, but before loading any other content. - /// - ///**NOTE for Android**: A constant to try to inject the script as soon as the page starts loading. - static const AT_DOCUMENT_START = const UserScriptInjectionTime._internal(0); - - ///**NOTE for iOS**: A constant to inject the script after the document finishes loading, but before loading any other subresources. - /// - ///**NOTE for Android**: A constant to inject the script as soon as the page finishes loading. - static const AT_DOCUMENT_END = const UserScriptInjectionTime._internal(1); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} - -///Class that represents a script that the [WebView] injects into the web page. -class UserScript { - ///The script’s group name. - String? groupName; - - ///The script’s source code. - String source; - - ///The time at which to inject the script into the [WebView]. - UserScriptInjectionTime injectionTime; - - ///Use [forMainFrameOnly] instead. - @Deprecated("Use forMainFrameOnly instead") - bool? iosForMainFrameOnly; - - ///A Boolean value that indicates whether to inject the script into the main frame. - ///Specify true to inject the script only into the main frame, or false to inject it into all frames. - ///The default value is `true`. - /// - ///**NOTE**: available only on iOS. - bool forMainFrameOnly; - - ///A scope of execution in which to evaluate the script to prevent conflicts between different scripts. - ///For more information about content worlds, see [ContentWorld]. - late ContentWorld contentWorld; - - UserScript( - {this.groupName, - required this.source, - required this.injectionTime, - @Deprecated("Use forMainFrameOnly instead") this.iosForMainFrameOnly, - this.forMainFrameOnly = true, - ContentWorld? contentWorld}) { - this.contentWorld = contentWorld ?? ContentWorld.PAGE; - // ignore: deprecated_member_use_from_same_package - this.forMainFrameOnly = this.iosForMainFrameOnly != null - // ignore: deprecated_member_use_from_same_package - ? this.iosForMainFrameOnly! - : this.forMainFrameOnly; - } - - Map toMap() { - return { - "groupName": groupName, - "source": source, - "injectionTime": injectionTime.toValue(), - "iosForMainFrameOnly": forMainFrameOnly, - "forMainFrameOnly": forMainFrameOnly, - "contentWorld": contentWorld.toMap() - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } -} - -final _contentWorldNameRegExp = RegExp(r'[\s]'); - -///Class that represents an object that defines a scope of execution for JavaScript code and which you use to prevent conflicts between different scripts. -/// -///**NOTE for iOS**: available on iOS 14.0+. This class represents the native [WKContentWorld](https://developer.apple.com/documentation/webkit/wkcontentworld) class. -/// -///**NOTE for Android**: it will create and append an `