Commit 08b392e8 authored by Lorenzo Pichilli's avatar Lorenzo Pichilli

updated docs, updated README.md

parent 3dd7d175
......@@ -16,14 +16,15 @@
<component name="ChangeListManager">
<list default="true" id="9b41f7a2-a71e-4923-91fb-249d7815b3e7" name="Default" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserActivity.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserActivity.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserFlutterPlugin.java" beforeDir="false" afterPath="$PROJECT_DIR$/android/src/main/java/com/pichillilorenzo/flutter_inappbrowser/InAppBrowserFlutterPlugin.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/assets/index.html" beforeDir="false" afterPath="$PROJECT_DIR$/example/assets/index.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/ios/Flutter/flutter_export_environment.sh" beforeDir="false" afterPath="$PROJECT_DIR$/example/ios/Flutter/flutter_export_environment.sh" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/lib/chrome_safari_browser_example.screen.dart" beforeDir="false" afterPath="$PROJECT_DIR$/example/lib/chrome_safari_browser_example.screen.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/lib/in_app_browser_example.screen.dart" beforeDir="false" afterPath="$PROJECT_DIR$/example/lib/in_app_browser_example.screen.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/README.md" beforeDir="false" afterPath="$PROJECT_DIR$/README.md" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/assets/certificate.pfx" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/example/lib/in_app_webiew_example.screen.dart" beforeDir="false" afterPath="$PROJECT_DIR$/example/lib/in_app_webiew_example.screen.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/lib/main.dart" beforeDir="false" afterPath="$PROJECT_DIR$/example/lib/main.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/example/pubspec.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/example/pubspec.yaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/src/chrome_safari_browser.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/chrome_safari_browser.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/src/cookie_manager.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/cookie_manager.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/src/in_app_browser.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/in_app_browser.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/src/in_app_webview.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/in_app_webview.dart" afterDir="false" />
<change beforePath="$PROJECT_DIR$/lib/src/webview_options.dart" beforeDir="false" afterPath="$PROJECT_DIR$/lib/src/webview_options.dart" afterDir="false" />
</list>
<ignored path="$PROJECT_DIR$/.dart_tool/" />
<ignored path="$PROJECT_DIR$/.idea/" />
......@@ -43,71 +44,37 @@
<component name="ExecutionTargetManager" SELECTED_TARGET="Pixel_3_XL_API_24" />
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/src/in_app_webview.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="7854">
<caret line="1362" column="38" selection-start-line="1362" selection-start-column="38" selection-end-line="1362" selection-end-column="38" />
<folding>
<element signature="e#0#17#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/example/lib/in_app_webiew_example.screen.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="219">
<caret line="33" column="24" selection-start-line="33" selection-start-column="24" selection-end-line="33" selection-end-column="24" />
<folding>
<element signature="e#0#39#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/example/lib/in_app_browser_example.screen.dart">
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/README.md">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="195">
<caret line="13" column="11" selection-start-line="13" selection-start-column="11" selection-end-line="13" selection-end-column="11" />
<state relative-caret-position="349">
<caret line="303" column="38" lean-forward="true" selection-start-line="303" selection-start-column="38" selection-end-line="303" selection-end-column="38" />
<folding>
<element signature="e#0#20#0" expanded="true" />
<element signature="e#0#39#0" expanded="true" />
<element signature="e#0#39#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/example/lib/chrome_safari_browser_example.screen.dart">
<entry file="file://$PROJECT_DIR$/lib/src/in_app_webview.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="345">
<caret line="23" selection-start-line="23" selection-end-line="23" />
<state relative-caret-position="325">
<caret line="1176" column="41" selection-start-line="1176" selection-start-column="41" selection-end-line="1176" selection-end-column="41" />
<folding>
<element signature="e#0#39#0" expanded="true" />
<element signature="e#0#17#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/example/assets/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180">
<caret line="12" column="26" selection-start-line="12" selection-start-column="26" selection-end-line="12" selection-end-column="26" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/example/lib/main.dart">
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="130">
<caret line="16" column="15" selection-start-line="16" selection-start-column="7" selection-end-line="16" selection-end-column="15" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
<state relative-caret-position="120">
<caret line="8" column="36" selection-start-line="8" selection-start-column="11" selection-end-line="8" selection-end-column="36" />
</state>
</provider>
</entry>
......@@ -124,22 +91,6 @@
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>onReceivedHttpAuthRequest</find>
<find>onLoadHtt</find>
<find>onLoadError</find>
<find>startSafeBrowsing</find>
<find>onSafeBrowsingHit</find>
<find>dispose</find>
<find>onSafe</find>
<find>192.1</find>
<find>flutter</find>
<find>InAppWebView</find>
<find>onFindResultReceived</find>
<find>highlighted</find>
<find>onLoadErr</find>
<find>InAppWebViewInitialFileTest</find>
<find>InAppWebViewInitialDataTest</find>
<find>Fetch</find>
<find>OnLoadHttpError</find>
<find>ONnaviga</find>
<find>InAppWebViewOnNavigationChangeTest</find>
......@@ -154,12 +105,29 @@
<find>InAppWebViewOnConsoleMessageTest</find>
<find>Change:</find>
<find>InAppWebViewOnScrollChangedTest</find>
<find>for Android</find>
<find>Event fired</find>
<find>an re</find>
<find>Event fires</find>
<find>only for Android.</find>
<find>isOpened</find>
<find>initialScale</find>
<find>e spinner when the WebView is loading a page. The default value i</find>
<find>reload</find>
<find>methods</find>
<find>class</find>
<find>HttpAuthCredentialDatabase</find>
<find>###</find>
<find>#####</find>
<find>loadFile</find>
<find>window.</find>
</findStrings>
<replaceStrings>
<replace>activity.getPreferences(0)</replace>
<replace>Log.</replace>
<replace>com.pichillilorenzo.flutter_inappbrowser</replace>
<replace>flutter_inappbrowser</replace>
<replace>Event fired</replace>
</replaceStrings>
<dirStrings>
<dir>$PROJECT_DIR$/example/android</dir>
......@@ -171,9 +139,6 @@
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/example/test_assets/in_app_webview_on_target_blank_test.html" />
<option value="$PROJECT_DIR$/CHANGELOG.md" />
<option value="$PROJECT_DIR$/lib/src/in_app_browser.dart" />
<option value="$PROJECT_DIR$/tool/env.dart" />
<option value="$PROJECT_DIR$/nodejs_server_test_auth_basic_and_ssl/index.js" />
<option value="$PROJECT_DIR$/example/test_assets/in_app_webview_on_navigation_change_test.html" />
......@@ -182,10 +147,8 @@
<option value="$PROJECT_DIR$/example/test_assets/in_app_webview_on_navigation_state_change_test.html" />
<option value="$PROJECT_DIR$/lib/src/content_blocker.dart" />
<option value="$PROJECT_DIR$/lib/src/types.dart" />
<option value="$PROJECT_DIR$/lib/src/cookie_manager.dart" />
<option value="$PROJECT_DIR$/example/test_driver/app.dart" />
<option value="$PROJECT_DIR$/example/test_driver/util_test.dart" />
<option value="$PROJECT_DIR$/lib/src/webview_options.dart" />
<option value="$PROJECT_DIR$/example/test_driver/custom_widget_test.dart" />
<option value="$PROJECT_DIR$/example/test_driver/in_app_webview_initial_url_test.dart" />
<option value="$PROJECT_DIR$/example/test_driver/in_app_webview_ajax_test.dart" />
......@@ -215,13 +178,18 @@
<option value="$PROJECT_DIR$/example/test_driver/in_app_webview_ssl_request_test.dart" />
<option value="$PROJECT_DIR$/example/test_driver/in_app_webview_http_auth_credential_database_test.dart" />
<option value="$PROJECT_DIR$/example/test_driver/in_app_webview_on_load_http_error_test.dart" />
<option value="$PROJECT_DIR$/lib/src/in_app_webview.dart" />
<option value="$PROJECT_DIR$/example/pubspec.yaml" />
<option value="$PROJECT_DIR$/example/lib/main.dart" />
<option value="$PROJECT_DIR$/example/lib/in_app_webiew_example.screen.dart" />
<option value="$PROJECT_DIR$/example/lib/in_app_browser_example.screen.dart" />
<option value="$PROJECT_DIR$/example/lib/chrome_safari_browser_example.screen.dart" />
<option value="$PROJECT_DIR$/example/assets/index.html" />
<option value="$PROJECT_DIR$/example/pubspec.yaml" />
<option value="$PROJECT_DIR$/lib/src/webview_options.dart" />
<option value="$PROJECT_DIR$/lib/src/in_app_browser.dart" />
<option value="$PROJECT_DIR$/example/lib/main.dart" />
<option value="$PROJECT_DIR$/lib/src/chrome_safari_browser.dart" />
<option value="$PROJECT_DIR$/example/lib/in_app_webiew_example.screen.dart" />
<option value="$PROJECT_DIR$/lib/src/cookie_manager.dart" />
<option value="$PROJECT_DIR$/README.md" />
<option value="$PROJECT_DIR$/lib/src/in_app_webview.dart" />
</list>
</option>
</component>
......@@ -276,6 +244,7 @@
<select />
</subPane>
</pane>
<pane id="PackagesPane" />
<pane id="ProjectPane">
<subPane>
<expand>
......@@ -283,23 +252,6 @@
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
<item name="example" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
<item name="example" type="462c0819:PsiDirectoryNode" />
<item name="assets" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
<item name="example" type="462c0819:PsiDirectoryNode" />
<item name="lib" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
......@@ -311,11 +263,6 @@
<item name="lib" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
<item name="flutter_inappbrowser" type="462c0819:PsiDirectoryNode" />
<item name="tool" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="flutter_inappbrowser" type="b2602c69:ProjectViewProjectNode" />
<item name="External Libraries" type="cb654da1:ExternalLibrariesNode" />
......@@ -324,7 +271,6 @@
<select />
</subPane>
</pane>
<pane id="PackagesPane" />
</panes>
</component>
<component name="PropertiesComponent">
......@@ -486,7 +432,7 @@
<window_info id="Resources Explorer" order="8" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" weight="0.32745314" />
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.49478307" visible="true" weight="0.4580311" />
<window_info anchor="bottom" id="Run" order="2" sideWeight="0.49478307" weight="0.4580311" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.34196892" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
......@@ -494,7 +440,7 @@
<window_info anchor="bottom" id="Android Profiler" order="7" show_stripe_button="false" />
<window_info anchor="bottom" id="Event Log" order="8" sideWeight="0.50532484" side_tool="true" weight="0.35751295" />
<window_info anchor="bottom" id="Version Control" order="9" />
<window_info anchor="bottom" id="Terminal" order="10" sideWeight="0.4946752" weight="0.38860103" />
<window_info anchor="bottom" id="Terminal" order="10" sideWeight="0.4946752" visible="true" weight="0.38860103" />
<window_info anchor="bottom" id="Logcat" order="11" weight="0.32953367" />
<window_info anchor="bottom" id="Messages" order="12" sideWeight="0.4968051" weight="0.33782384" />
<window_info anchor="bottom" id="Dependency Viewer" order="13" weight="0.32800853" />
......@@ -524,41 +470,6 @@
</ignored-roots>
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/test.sh">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90">
<caret line="6" selection-start-line="6" selection-end-line="6" selection-end-column="38" />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/flutter/packages/flutter/lib/src/widgets/framework.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-654">
<caret line="936" column="15" selection-start-line="936" selection-start-column="15" selection-end-line="936" selection-end-column="15" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/content_blocker.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2025">
<caret line="135" column="1" selection-start-line="135" selection-start-column="1" selection-end-line="135" selection-end-column="1" />
<folding>
<element signature="e#0#41#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/cookie_manager.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="633">
<caret line="71" column="19" selection-start-line="71" selection-start-column="19" selection-end-line="71" selection-end-column="19" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/test_driver/util_test.dart" />
<entry file="file://$USER_HOME$/flutter/packages/flutter_driver/lib/src/driver/driver.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="177">
......@@ -566,16 +477,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/webview_options.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="283">
<caret line="322" column="61" selection-start-line="322" selection-start-column="49" selection-end-line="322" selection-end-column="61" />
<folding>
<element signature="e#0#17#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/test_driver/in_app_webview_ajax_test.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180">
......@@ -586,16 +487,6 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/test_driver/in_app_webview_initial_url_test.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="202">
<caret line="21" column="30" lean-forward="true" selection-start-line="21" selection-start-column="30" selection-end-line="21" selection-end-column="30" />
<folding>
<element signature="e#0#39#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/test_driver/in_app_webview_content_blocker_test.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="315">
......@@ -897,85 +788,153 @@
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/lib/test.dart">
<entry file="file://$PROJECT_DIR$/example/lib/test.dart" />
<entry file="file://$PROJECT_DIR$/example/assets/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180">
<caret line="12" column="26" selection-start-line="12" selection-start-column="26" selection-end-line="12" selection-end-column="26" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/pubspec.yaml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="319">
<caret line="43" column="9" selection-start-line="43" selection-start-column="9" selection-end-line="43" selection-end-column="9" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/lib/in_app_browser_example.screen.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-5596">
<state relative-caret-position="135">
<caret line="9" column="25" selection-start-line="9" selection-start-column="9" selection-end-line="9" selection-end-column="25" />
<folding>
<element signature="e#0#16431#0" expanded="true" />
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/in_app_localhost_server.dart">
<entry file="file://$PROJECT_DIR$/example/lib/chrome_safari_browser_example.screen.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-845">
<state relative-caret-position="75">
<caret line="5" selection-start-line="5" selection-end-line="22" selection-end-column="1" />
<folding>
<element signature="e#0#17#0" expanded="true" />
<element signature="e#0#39#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/pubspec.yaml">
<entry file="file://$PROJECT_DIR$/lib/src/in_app_browser.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="330">
<caret line="22" column="23" selection-start-line="22" selection-start-column="23" selection-end-line="22" selection-end-column="23" />
<state relative-caret-position="178">
<caret line="278" column="2" selection-start-line="278" selection-start-column="2" selection-end-line="278" selection-end-column="80" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/in_app_webview.dart">
<entry file="file://$PROJECT_DIR$/lib/src/chrome_safari_browser.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="7854">
<caret line="1362" column="38" selection-start-line="1362" selection-start-column="38" selection-end-line="1362" selection-end-column="38" />
<state relative-caret-position="397">
<caret line="105" column="3" selection-start-line="92" selection-start-column="2" selection-end-line="105" selection-end-column="3" />
<folding>
<element signature="e#0#17#0" expanded="true" />
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/test_driver/in_app_webview_initial_url_test.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="202">
<caret line="21" column="30" selection-start-line="21" selection-start-column="30" selection-end-line="21" selection-end-column="30" />
<folding>
<element signature="e#0#39#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/lib/main.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="130">
<caret line="16" column="15" selection-start-line="16" selection-start-column="7" selection-end-line="16" selection-end-column="15" />
<state relative-caret-position="528">
<caret line="57" column="11" selection-start-line="57" selection-start-column="11" selection-end-line="57" selection-end-column="11" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/in_app_localhost_server.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-65">
<folding>
<element signature="e#0#17#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/cookie_manager.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="135">
<caret line="14" column="45" lean-forward="true" selection-start-line="14" selection-start-column="5" selection-end-line="14" selection-end-column="45" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/lib/in_app_webiew_example.screen.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="219">
<caret line="33" column="24" selection-start-line="33" selection-start-column="24" selection-end-line="33" selection-end-column="24" />
<state relative-caret-position="120">
<caret line="35" column="22" lean-forward="true" selection-start-line="35" selection-start-column="22" selection-end-line="35" selection-end-column="22" />
<folding>
<element signature="e#0#39#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/lib/in_app_browser_example.screen.dart">
<entry file="file://$PROJECT_DIR$/lib/src/http_auth_credentials_database.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="195">
<caret line="13" column="11" selection-start-line="13" selection-start-column="11" selection-end-line="13" selection-end-column="11" />
<state relative-caret-position="366">
<caret line="96" column="65" lean-forward="true" selection-start-line="96" selection-start-column="5" selection-end-line="96" selection-end-column="65" />
<folding>
<element signature="e#0#20#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/lib/chrome_safari_browser_example.screen.dart">
<entry file="file://$PROJECT_DIR$/lib/src/webview_options.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="345">
<caret line="23" selection-start-line="23" selection-end-line="23" />
<state relative-caret-position="141">
<caret line="606" column="95" selection-start-line="606" selection-start-column="30" selection-end-line="606" selection-end-column="95" />
<folding>
<element signature="e#0#39#0" expanded="true" />
<element signature="e#0#17#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/assets/index.html">
<entry file="file://$PROJECT_DIR$/pubspec.yaml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180">
<caret line="12" column="26" selection-start-line="12" selection-start-column="26" selection-end-line="12" selection-end-column="26" />
<state relative-caret-position="120">
<caret line="8" column="36" selection-start-line="8" selection-start-column="11" selection-end-line="8" selection-end-column="36" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/src/in_app_webview.dart">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="325">
<caret line="1176" column="41" selection-start-line="1176" selection-start-column="41" selection-end-line="1176" selection-end-column="41" />
<folding>
<element signature="e#0#17#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/README.md">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="349">
<caret line="303" column="38" lean-forward="true" selection-start-line="303" selection-start-column="38" selection-end-line="303" selection-end-column="38" />
<folding>
<element signature="e#0#20#0" expanded="true" />
<element signature="e#0#39#0" expanded="true" />
<element signature="e#0#39#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
......
......@@ -10,17 +10,20 @@
A Flutter plugin that allows you to add an inline webview or open an in-app browser window.
### Requirements
- Dart sdk: ">=2.1.0-dev.7.1 <3.0.0"
- Flutter: ">=0.10.1 <2.0.0"
- Dart sdk: ">=2.0.0-dev.68.0 <3.0.0"
- Flutter: ">=1.9.1+hotfix.5 <2.0.0"
- Android: `minSdkVersion 17`
- iOS: `--ios-language swift`
### Note for Android
During the build, if Android fails with `Error: uses-sdk:minSdkVersion 16 cannot be smaller than version 17 declared in library`, it means that you need to update the `minSdkVersion` of your `build.gradle` file to at least `17`.
Because of [Flutter AndroidX compatibility](https://flutter.dev/docs/development/packages-and-plugins/androidx-compatibility), the latest version that doesn't use `AndroidX` is `0.6.0`.
### IMPORTANT Note for iOS
If you are starting a new fresh app, you need to create the Flutter App with `flutter create -i swift` (see [flutter/flutter#13422 (comment)](https://github.com/flutter/flutter/issues/13422#issuecomment-392133780)), otherwise, you will get this message:
```
=== BUILD TARGET flutter_inappbrowser OF PROJECT Pods WITH CONFIGURATION Debug ===
......@@ -54,23 +57,54 @@ For help getting started with Flutter, view our online
For help on editing plugin code, view the [documentation](https://flutter.io/developing-packages/#edit-plugin-package).
## Installation
First, add `flutter_inappbrowser` as a [dependency in your pubspec.yaml file](https://flutter.io/using-packages/).
## Usage
Classes:
- [InAppWebView](#inappwebview-class): Flutter Widget for adding an **inline native WebView** integrated into the flutter widget tree. To use `InAppWebView` class on iOS you need to opt-in for the embedded views preview by adding a boolean property to the app's `Info.plist` file, with the key `io.flutter.embedded_views_preview` and the value `YES`.
- [InAppBrowser](#inappbrowser-class): In-App Browser using native WebView.
- [ChromeSafariBrowser](#chromesafaribrowser-class): In-App Browser using [Chrome Custom Tabs](https://developer.android.com/reference/android/support/customtabs/package-summary) on Android / [SFSafariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller) on iOS.
- [InAppLocalhostServer](#inapplocalhostserver-class): This class allows you to create a simple server on `http://localhost:[port]/`. The default `port` value is `8080`.
- [CookieManager](#cookiemanager-class): Manages the cookies used by WebView instances. **NOTE for iOS**: available from iOS 11.0+.
- [CookieManager](#cookiemanager-class): This class implements a singleton object (shared instance) which manages the cookies used by WebView instances. **NOTE for iOS**: available from iOS 11.0+.
- [HttpAuthCredentialDatabase](#httpauthcredentialdatabase-class): This class implements a singleton object (shared instance) which manages the shared HTTP auth credentials cache.
## API Reference
See the online [API Reference](https://pub.dartlang.org/documentation/flutter_inappbrowser/latest/) to get the full documentation.
### Load a file inside `assets` folder
See the online [docs](https://pub.dartlang.org/documentation/flutter_inappbrowser/latest/) to get the full documentation.
To be able to load your local files (assets, js, css, etc.), you need to add them in the `assets` section of the `pubspec.yaml` file, otherwise they cannot be found!
Example of a `pubspec.yaml` file:
```yaml
...
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
assets:
- assets/index.html
- assets/css/
- assets/images/
...
```
### `InAppWebView` class
Flutter Widget for adding an **inline native WebView** integrated into the flutter widget tree.
The plugin relies on Flutter's mechanism (in developers preview) for embedding Android and iOS native views: [AndroidView](https://docs.flutter.io/flutter/widgets/AndroidView-class.html) and [UiKitView](https://docs.flutter.io/flutter/widgets/UiKitView-class.html).
Known issues are tagged with the [platform-views](https://github.com/flutter/flutter/labels/a%3A%20platform-views) label in the [Flutter official repo](https://github.com/flutter/flutter).
Keyboard support within webviews is also experimental.
To use `InAppWebView` class on iOS you need to opt-in for the embedded views preview by adding a boolean property to the app's `Info.plist` file, with the key `io.flutter.embedded_views_preview` and the value `YES`.
......@@ -111,96 +145,84 @@ class _MyAppState extends State<MyApp> {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Inline WebView example app'),
title: const Text('InAppWebView Example'),
),
body: Container(
child: Column(
children: <Widget>[
Container(
padding: EdgeInsets.all(20.0),
child: Text("CURRENT URL\n${ (url.length > 50) ? url.substring(0, 50) + "..." : url }"),
),
(progress != 1.0) ? LinearProgressIndicator(value: progress) : Container(),
Expanded(
child: Container(
margin: const EdgeInsets.all(10.0),
decoration: BoxDecoration(
border: Border.all(color: Colors.blueAccent)
),
child: InAppWebView(
initialUrl: "https://flutter.io/",
initialHeaders: {
},
initialOptions: {
},
onWebViewCreated: (InAppWebViewController controller) {
webView = controller;
},
onLoadStart: (InAppWebViewController controller, String url) {
print("started $url");
setState(() {
this.url = url;
});
},
onProgressChanged: (InAppWebViewController controller, int progress) {
setState(() {
this.progress = progress/100;
});
},
child: Column(children: <Widget>[
Container(
padding: EdgeInsets.all(20.0),
child: Text(
"CURRENT URL\n${(url.length > 50) ? url.substring(0, 50) + "..." : url}"),
),
Container(
padding: EdgeInsets.all(10.0),
child: progress < 1.0
? LinearProgressIndicator(value: progress)
: Container()),
Expanded(
child: Container(
margin: const EdgeInsets.all(10.0),
decoration:
BoxDecoration(border: Border.all(color: Colors.blueAccent)),
child: InAppWebView(
initialUrl: "https://flutter.dev/",
initialHeaders: {},
initialOptions: InAppWebViewWidgetOptions(
inAppWebViewOptions: InAppWebViewOptions(
debuggingEnabled: true,
)
),
onWebViewCreated: (InAppWebViewController controller) {
webView = controller;
},
onLoadStart: (InAppWebViewController controller, String url) {
setState(() {
this.url = url;
});
},
onLoadStop: (InAppWebViewController controller, String url) async {
setState(() {
this.url = url;
});
},
onProgressChanged: (InAppWebViewController controller, int progress) {
setState(() {
this.progress = progress / 100;
});
},
),
),
ButtonBar(
alignment: MainAxisAlignment.center,
children: <Widget>[
RaisedButton(
child: Icon(Icons.arrow_back),
onPressed: () {
if (webView != null) {
webView.goBack();
}
},
),
RaisedButton(
child: Icon(Icons.arrow_forward),
onPressed: () {
if (webView != null) {
webView.goForward();
}
},
),
RaisedButton(
child: Icon(Icons.refresh),
onPressed: () {
if (webView != null) {
webView.reload();
}
},
),
],
),
].where((Object o) => o != null).toList(),
),
),
bottomNavigationBar: BottomNavigationBar(
currentIndex: 0,
items: [
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text('Home'),
),
BottomNavigationBarItem(
icon: Icon(Icons.mail),
title: Text('Item 2'),
ButtonBar(
alignment: MainAxisAlignment.center,
children: <Widget>[
RaisedButton(
child: Icon(Icons.arrow_back),
onPressed: () {
if (webView != null) {
webView.goBack();
}
},
),
RaisedButton(
child: Icon(Icons.arrow_forward),
onPressed: () {
if (webView != null) {
webView.goForward();
}
},
),
RaisedButton(
child: Icon(Icons.refresh),
onPressed: () {
if (webView != null) {
webView.reload();
}
},
),
],
),
BottomNavigationBarItem(
icon: Icon(Icons.person),
title: Text('Item 3')
)
],
),
])),
),
);
}
......@@ -216,441 +238,218 @@ Screenshots:
![ios](https://user-images.githubusercontent.com/5956938/54096363-e1e72000-43ab-11e9-85c2-983a830ab7a0.gif)
#### InAppWebView.initialUrl
Initial url that will be loaded.
#### InAppWebView.initialFile
Initial asset file that will be loaded. See `InAppWebView.loadFile()` for explanation.
#### InAppWebView.initialData
Initial `InAppWebViewInitialData` that will be loaded.
#### InAppWebView.initialHeaders
Initial headers that will be used.
#### InAppWebView.initialOptions
Initial options that will be used.
All platforms support:
- __useShouldOverrideUrlLoading__: Set to `true` to be able to listen at the `shouldOverrideUrlLoading()` event. The default value is `false`.
- __useOnLoadResource__: Set to `true` to be able to listen at the `onLoadResource()` event. The default value is `false`.
- __clearCache__: Set to `true` to have all the browser's cache cleared before the new window is opened. The default value is `false`.
- __userAgent__: Set the custom WebView's user-agent.
- __javaScriptEnabled__: Set to `true` to enable JavaScript. The default value is `true`.
- __javaScriptCanOpenWindowsAutomatically__: Set to `true` to allow JavaScript open windows without user interaction. The default value is `false`.
- __mediaPlaybackRequiresUserGesture__: Set to `true` to prevent HTML5 audio or video from autoplaying. The default value is `true`.
- __transparentBackground__: Set to `true` to make the background of the WebView transparent. If your app has a dark theme, this can prevent a white flash on initialization. The default value is `false`.
**Android** supports these additional options:
- __clearSessionCache__: Set to `true` to have the session cookie cache cleared before the new window is opened.
- __builtInZoomControls__: Set to `true` if the WebView should use its built-in zoom mechanisms. The default value is `false`.
- __displayZoomControls__: Set to `true` if the WebView should display on-screen zoom controls when using the built-in zoom mechanisms. The default value is `false`.
- __supportZoom__: Set to `false` if the WebView should not support zooming using its on-screen zoom controls and gestures. The default value is `true`.
- __databaseEnabled__: Set to `true` if you want the database storage API is enabled. The default value is `false`.
- __domStorageEnabled__: Set to `true` if you want the DOM storage API is enabled. The default value is `false`.
- __useWideViewPort__: Set to `true` if the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport. When the value of the setting is false, the layout width is always set to the width of the WebView control in device-independent (CSS) pixels. When the value is true and the page contains the viewport meta tag, the value of the width specified in the tag is used. If the page does not contain the tag or does not provide a width, then a wide viewport will be used. The default value is `true`.
- __safeBrowsingEnabled__: Set to `true` if you want the Safe Browsing is enabled. Safe Browsing allows WebView to protect against malware and phishing attacks by verifying the links. The default value is `true`.
- __textZoom__: Set text scaling of the WebView. The default value is `100`.
- __mixedContentMode__: Configures the WebView's behavior when a secure origin attempts to load a resource from an insecure origin. By default, apps that target `Build.VERSION_CODES.KITKAT` or below default to `MIXED_CONTENT_ALWAYS_ALLOW`. Apps targeting `Build.VERSION_CODES.LOLLIPOP` default to `MIXED_CONTENT_NEVER_ALLOW`. The preferred and most secure mode of operation for the WebView is `MIXED_CONTENT_NEVER_ALLOW` and use of `MIXED_CONTENT_ALWAYS_ALLOW` is strongly discouraged.
**iOS** supports these additional options:
- __disallowOverScroll__: Set to `true` to disable the bouncing of the WebView when the scrolling has reached an edge of the content. The default value is `false`.
- __enableViewportScale__: Set to `true` to allow a viewport meta tag to either disable or restrict the range of user scaling. The default value is `false`.
- __suppressesIncrementalRendering__: Set to `true` if you want the WebView suppresses content rendering until it is fully loaded into memory.. The default value is `false`.
- __allowsAirPlayForMediaPlayback__: Set to `true` to allow AirPlay. The default value is `true`.
- __allowsBackForwardNavigationGestures__: Set to `true` to allow the horizontal swipe gestures trigger back-forward list navigations. The default value is `true`.
- __allowsLinkPreview__: Set to `true` to allow that pressing on a link displays a preview of the destination for the link. The default value is `true`.
- __ignoresViewportScaleLimits__: Set to `true` if you want that the WebView should always allow scaling of the webpage, regardless of the author's intent. The ignoresViewportScaleLimits property overrides the `user-scalable` HTML property in a webpage. The default value is `false`.
- __allowsInlineMediaPlayback__: Set to `true` to allow HTML5 media playback to appear inline within the screen layout, using browser-supplied controls rather than native controls. For this to work, add the `webkit-playsinline` attribute to any `<video>` elements. The default value is `false`.
- __allowsPictureInPictureMediaPlayback__: Set to `true` to allow HTML5 videos play picture-in-picture. The default value is `true`.
#### Events
Event `onWebViewCreated` fires when the `InAppWebView` is created.
```dart
InAppWebView(
initialUrl: "https://flutter.io/",
onWebViewCreated: (InAppWebViewController controller) {}
}
```
Event `onLoadStart` fires when the `InAppWebView` starts to load an `url`.
```dart
InAppWebView(
initialUrl: "https://flutter.io/",
onLoadStart: (InAppWebViewController controller, String url) {}
}
```
Event `onLoadStop` fires when the `InAppWebView` finishes loading an `url`.
```dart
InAppWebView(
initialUrl: "https://flutter.io/",
onLoadStop: (InAppWebViewController controller, String url) {}
}
```
Event `onLoadError` fires when the `InAppWebView` encounters an error loading an `url`.
```dart
InAppWebView(
initialUrl: "https://flutter.io/",
onLoadError: (InAppWebViewController controller, String url, int code, String message) {}
}
```
Event `onProgressChanged` fires when the current `progress` (range 0-100) of loading a page is changed.
```dart
InAppWebView(
initialUrl: "https://flutter.io/",
onProgressChanged: (InAppWebViewController controller, int progress) {}
}
```
Event `onConsoleMessage` fires when the `InAppWebView` receives a `ConsoleMessage`.
```dart
InAppWebView(
initialUrl: "https://flutter.io/",
onConsoleMessage: (InAppWebViewController controller, ConsoleMessage consoleMessage) {}
}
```
`shouldOverrideUrlLoading`: Give the host application a chance to take control when a URL is about to be loaded in the current WebView.
**NOTE**: In order to be able to listen this event, you need to set `useShouldOverrideUrlLoading` option to `true`.
```dart
InAppWebView(
initialUrl: "https://flutter.io/",
shouldOverrideUrlLoading: (InAppWebViewController controller, String url) {}
}
```
Event `onLoadResource` fires when the `InAppWebView` webview loads a resource.
**NOTE**: In order to be able to listen this event, you need to set `useOnLoadResource` option to `true`.
**NOTE only for iOS**: In some cases, the `response.data` of a `response` with `text/html` encoding could be empty.
```dart
InAppWebView(
initialUrl: "https://flutter.io/",
onLoadResource: (InAppWebViewController controller, WebResourceResponse response, WebResourceRequest request) {}
}
```
Event `onScrollChanged` fires when the `InAppWebView` scrolls.
`x` represents the current horizontal scroll origin in pixels.
`y` represents the current vertical scroll origin in pixels.
```dart
InAppWebView(
initialUrl: "https://flutter.io/",
onScrollChanged: (InAppWebViewController controller, int x, int y) {}
}
```
#### Future\<String\> InAppWebViewController.getUrl
Gets the URL for the current page.
This is not always the same as the URL passed to `InAppWebView.onLoadStarted` because although the load for that URL has begun, the current page may not have changed.
```dart
inAppWebViewController.getUrl();
```
#### Future\<String\> InAppWebViewController.getTitle
Gets the title for the current page.
```dart
inAppWebViewController.getTitle();
```
#### Future\<int\> InAppWebViewController.getProgress
Gets the progress for the current page. The progress value is between 0 and 100.
```dart
inAppWebViewController.getProgress();
```
#### Future\<List\<int\>\> InAppWebViewController.getFavicon
Gets the favicon for the current page.
```dart
inAppWebViewController.getFavicon();
```
#### Future\<void\> InAppWebViewController.loadUrl
Loads the given `url` with optional `headers` specified as a map from name to value.
```dart
inAppWebViewController.loadUrl(String url, {Map<String, String> headers = const {}});
```
#### Future\<void\> InAppWebViewController.postUrl
Loads the given `url` with `postData` using `POST` method into this WebView.
```dart
inAppWebViewController.postUrl(String url, Uint8List postData);
```
#### Future\<void\> InAppWebViewController.loadData
Loads the given `data` into this WebView, using `baseUrl` as the base URL for the content.
The `mimeType` parameter specifies the format of the data.
The `encoding` parameter specifies the encoding of the data.
```dart
inAppWebViewController.loadData(String data, {String mimeType = "text/html", String encoding = "utf8", String baseUrl = "about:blank"});
```
#### Future\<void\> InAppWebViewController.loadFile
Loads the given `assetFilePath` with optional `headers` specified as a map from name to value.
To be able to load your local files (html, js, css, etc.), you need to add them in the `assets` section of the `pubspec.yaml` file, otherwise they cannot be found!
Example of a `pubspec.yaml` file:
```yaml
...
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
assets:
- assets/index.html
- assets/css/
- assets/images/
...
```
Example of a `main.dart` file:
```dart
...
inAppWebViewController.loadFile("assets/index.html");
...
```
```dart
inAppWebViewController.loadFile(String assetFilePath, {Map<String, String> headers = const {}});
```
#### Future\<void\> InAppWebViewController.reload
Reloads the `InAppWebView` window.
```dart
inAppWebViewController.reload();
```
#### Future\<void\> InAppWebViewController.goBack
Goes back in the history of the `InAppWebView` window.
```dart
inAppWebViewController.goBack();
```
#### Future\<bool\> InAppWebViewController.canGoBack
Returns a boolean value indicating whether the `InAppWebView` can move backward.
```dart
inAppWebViewController.canGoBack();
```
#### Future\<void\> InAppWebViewController.goForward
Goes forward in the history of the `InAppWebView` window.
```dart
inAppWebViewController.goForward();
```
#### Future\<bool\> InAppWebViewController.canGoForward
Returns a boolean value indicating whether the `InAppWebView` can move forward.
```dart
inAppWebViewController.canGoForward();
```
#### Future\<void\> InAppWebViewController.goBackOrForward
Goes to the history item that is the number of steps away from the current item. Steps is negative if backward and positive if forward.
```dart
inAppWebViewController.goBackOrForward(int steps);
```
#### Future\<bool\> InAppWebViewController.canGoBackOrForward
Returns a boolean value indicating whether the `InAppWebView` can go back or forward the given number of steps. Steps is negative if backward and positive if forward.
```dart
inAppWebViewController.canGoBackOrForward(int steps);
```
#### Future\<void\> InAppWebViewController.goTo
Navigates to a `WebHistoryItem` from the back-forward `WebHistory.list` and sets it as the current item.
```dart
inAppWebViewController.goTo(WebHistoryItem historyItem);
```
#### Future\<bool\> InAppWebViewController.isLoading
Check if the Web View of the `InAppWebView` instance is in a loading state.
```dart
inAppWebViewController.isLoading();
```
#### Future\<void\> InAppWebViewController.stopLoading
Stops the Web View of the `InAppWebView` instance from loading.
```dart
inAppWebViewController.stopLoading();
```
#### Future\<String\> InAppWebViewController.injectScriptCode
Injects JavaScript code into the `InAppWebView` window and returns the result of the evaluation.
```dart
inAppWebViewController.injectScriptCode(String source);
```
#### Future\<void\> InAppWebViewController.injectScriptFile
Injects a JavaScript file into the `InAppWebView` window.
```dart
inAppWebViewController.injectScriptFile(String urlFile);
```
#### Future\<void\> InAppWebViewController.injectStyleCode
Injects CSS into the `InAppWebView` window.
```dart
inAppWebViewController.injectStyleCode(String source);
```
#### Future\<void\> InAppWebViewController.injectStyleFile
Injects a CSS file into the `InAppWebView` window.
```dart
inAppWebViewController.injectStyleFile(String urlFile);
```
#### void InAppWebViewController.addJavaScriptHandler
Adds a JavaScript message handler `callback` (`JavaScriptHandlerCallback`) that listen to post messages sent from JavaScript by the handler with name `handlerName`.
#### `InAppWebViewController` Methods
* `getUrl`: Gets the URL for the current page.
* `getTitle`: Gets the title for the current page.
* `getProgress`: Gets the progress for the current page. The progress value is between 0 and 100.
* `getHtml`: Gets the content html of the page.
* `getFavicons`: Gets the list of all favicons for the current page.
* `loadUrl({@required String url, Map<String, String> headers = const {}})`: Loads the given url with optional headers specified as a map from name to value.
* `postUrl({@required String url, @required Uint8List postData})`: Loads the given url with postData using `POST` method into this WebView.
* `loadData({@required String data, String mimeType = "text/html", String encoding = "utf8", String baseUrl = "about:blank"})`: Loads the given data into this WebView.
* `loadFile({@required String assetFilePath, Map<String, String> headers = const {}})`: Loads the given `assetFilePath` with optional headers specified as a map from name to value.
* `reload`: Reloads the WebView.
* `goBack`: Goes back in the history of the WebView.
* `canGoBack`: Returns a boolean value indicating whether the WebView can move backward.
* `goForward`: Goes forward in the history of the WebView.
* `canGoForward`: Returns a boolean value indicating whether the WebView can move forward.
* `goBackOrForward({@required int steps})`: Goes to the history item that is the number of steps away from the current item. Steps is negative if backward and positive if forward.
* `canGoBackOrForward({@required int steps})`: Returns a boolean value indicating whether the WebView can go back or forward the given number of steps. Steps is negative if backward and positive if forward.
* `goTo({@required WebHistoryItem historyItem})`: Navigates to a `WebHistoryItem` from the back-forward `WebHistory.list` and sets it as the current item.
* `isLoading`: Check if the WebView instance is in a loading state.
* `stopLoading`: Stops the WebView from loading.
* `evaluateJavascript({@required String source})`: Evaluates JavaScript code into the WebView and returns the result of the evaluation.
* `injectJavascriptFileFromUrl({@required String urlFile})`: Injects an external JavaScript file into the WebView from a defined url.
* `injectJavascriptFileFromAsset({@required String assetFilePath})`: Injects a JavaScript file into the WebView from the flutter assets directory.
* `injectCSSCode({@required String source})`: Injects CSS into the WebView.
* `injectCSSFileFromUrl({@required String urlFile})`: Injects an external CSS file into the WebView from a defined url.
* `injectCSSFileFromAsset({@required String assetFilePath})`: Injects a CSS file into the WebView from the flutter assets directory.
* `addJavaScriptHandler({@required String handlerName, @required JavaScriptHandlerCallback callback})`: Adds a JavaScript message handler callback that listen to post messages sent from JavaScript by the handler with name `handlerName`.
* `removeJavaScriptHandler({@required String handlerName})`: Removes a JavaScript message handler previously added with the `addJavaScriptHandler()` associated to `handlerName` key.
* `takeScreenshot`: Takes a screenshot (in PNG format) of the WebView's visible viewport and returns a `Uint8List`. Returns `null` if it wasn't be able to take it.
* `setOptions({@required InAppWebViewWidgetOptions options})`: Sets the WebView options with the new options and evaluates them.
* `getOptions`: Gets the current WebView options. Returns the options with `null` value if they are not set yet.
* `getCopyBackForwardList`: Gets the `WebHistory` for this WebView. This contains the back/forward list for use in querying each item in the history stack.
* `startSafeBrowsing`: Starts Safe Browsing initialization (available only on Android).
* `setSafeBrowsingWhitelist({@required List<String> hosts})`: Sets the list of hosts (domain names/IP addresses) that are exempt from SafeBrowsing checks. The list is global for all the WebViews (available only on Android).
* `getSafeBrowsingPrivacyPolicyUrl`: Returns a URL pointing to the privacy policy for Safe Browsing reporting. This value will never be `null`.
* `clearCache`: Clears all the webview's cache.
* `clearSslPreferences`: Clears the SSL preferences table stored in response to proceeding with SSL certificate errors (available only on Android).
* `clearClientCertPreferences`: Clears the client certificate preferences stored in response to proceeding/cancelling client cert requests (available only on Android).
* `findAllAsync({@required String find})`: Finds all instances of find on the page and highlights them. Notifies `onFindResultReceived` listener.
* `findNext({@required bool forward})`: Highlights and scrolls to the next match found by `findAllAsync()`. Notifies `onFindResultReceived` listener.
* `clearMatches`: Clears the highlighting surrounding text matches created by `findAllAsync()`.
* `getTRexRunnerHtml`: Gets the html (with javascript) of the Chromium's t-rex runner game. Used in combination with `getTRexRunnerCss()`.
* `getTRexRunnerCss`: Gets the css of the Chromium's t-rex runner game. Used in combination with `getTRexRunnerHtml()`.
* `scrollTo({@required int x, @required int y})`: Scrolls the WebView to the position.
* `scrollBy({@required int x, @required int y})`: Moves the scrolled position of the WebView.
##### About the JavaScript handler
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_inappbrowser.callHandler(handlerName <String>, ...args);`, where `args` are [rest parameters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters).
The JavaScript function that can be used to call the handler is `window.flutter_inappbrowser.callHandler(handlerName <String>, ...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.
In order to call `window.flutter_inappbrowser.callHandler(handlerName <String>, ...args)` properly, you need to wait and listen the JavaScript event `flutterInAppBrowserPlatformReady`.
This event will be dispatch as soon as the platform (Android or iOS) is ready to handle the `callHandler` method.
This event will be dispatched as soon as the platform (Android or iOS) is ready to handle the `callHandler` method.
```javascript
window.addEventListener("flutterInAppBrowserPlatformReady", function(event) {
console.log("ready");
});
window.addEventListener("flutterInAppBrowserPlatformReady", function(event) {
console.log("ready");
});
```
`window.flutter_inappbrowser.callHandler` returns a JavaScript [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
that can be used to get the json result returned by `JavaScriptHandlerCallback`.
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.
that can be used to get the json result returned by [JavaScriptHandlerCallback].
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.
So, on the JavaScript side, to get data coming from the Dart side, you will use:
```html
<script>
window.addEventListener("flutterInAppBrowserPlatformReady", function(event) {
window.flutter_inappbrowser.callHandler('handlerFoo').then(function(result) {
console.log(result, typeof result);
console.log(JSON.stringify(result));
});
window.flutter_inappbrowser.callHandler('handlerFooWithArgs', 1, true, ['bar', 5], {foo: 'baz'}).then(function(result) {
console.log(result, typeof result);
console.log(JSON.stringify(result));
});
});
window.addEventListener("flutterInAppBrowserPlatformReady", function(event) {
window.flutter_inappbrowser.callHandler('handlerFoo').then(function(result) {
console.log(result);
});
window.flutter_inappbrowser.callHandler('handlerFooWithArgs', 1, true, ['bar', 5], {foo: 'baz'}).then(function(result) {
console.log(result);
});
});
</script>
```
Instead, on the `onLoadStop` WebView event, you can use `callHandler` directly:
```dart
// Inject JavaScript that will receive data back from Flutter
inAppWebViewController.injectScriptCode("""
window.flutter_inappbrowser.callHandler('test', 'Text from Javascript').then(function(result) {
console.log(result);
});
""");
```
```dart
inAppWebViewController.addJavaScriptHandler(String handlerName, JavaScriptHandlerCallback callback);
```
#### JavaScriptHandlerCallback InAppWebViewController.removeJavaScriptHandler
Removes a JavaScript message handler previously added with the `addJavaScriptHandler()` associated to `handlerName` key.
Returns the value associated with `handlerName` before it was removed.
Returns `null` if `handlerName` was not found.
```dart
inAppWebViewController.removeJavaScriptHandler(String handlerName);
```
#### Future\<Uint8List\> InAppWebViewController.takeScreenshot
Takes a screenshot (in PNG format) of the WebView's visible viewport and returns a `Uint8List`. Returns `null` if it wasn't be able to take it.
**NOTE for iOS**: available from iOS 11.0+.
```dart
inAppWebViewController.takeScreenshot();
```
#### Future\<void\> InAppWebViewController.setOptions
Sets the `InAppWebView` options with the new `options` and evaluates them.
```dart
inAppWebViewController.setOptions(Map<String, dynamic> options);
```
#### Future\<Map\<String, dynamic\>\> InAppWebViewController.getOptions
Gets the current `InAppWebView` options. Returns `null` if the options are not setted yet.
```dart
inAppWebViewController.getOptions();
```
#### Future\<WebHistory\> InAppWebViewController.getCopyBackForwardList
Gets the WebHistory for this WebView. This contains the back/forward list for use in querying each item in the history stack.
This contains only a snapshot of the current state.
Multiple calls to this method may return different objects.
The object returned from this method will not be updated to reflect any new state.
```dart
inAppWebViewController.getCopyBackForwardList();
```
// Inject JavaScript that will receive data back from Flutter
inAppWebViewController.evaluateJavascript(source: """
window.flutter_inappbrowser.callHandler('test', 'Text from Javascript').then(function(result) {
console.log(result);
});
""");
```
#### `InAppWebView` options
##### `InAppWebView` Cross-platform options
* `useShouldOverrideUrlLoading`: Set to `true` to be able to listen at the `shouldOverrideUrlLoading` event. The default value is `false`.
* `useOnLoadResource`: Set to `true` to be able to listen at the `onLoadResource` event. The default value is `false`.
* `useOnDownloadStart`: Set to `true` to be able to listen at the `onDownloadStart` event. The default value is `false`.
* `useOnTargetBlank`: Set to `true` to be able to listen at the `onTargetBlank` event. The default value is `false`.
* `clearCache`: Set to `true` to have all the browser's cache cleared before the new window is opened. The default value is `false`.
* `userAgent`: Sets the user-agent for the WebView.
* `applicationNameForUserAgent`: Append to the existing user-agent. Setting userAgent will override this.
* `javaScriptEnabled`: Set to `true` to enable JavaScript. The default value is `true`.
* `debuggingEnabled`: Enables debugging of web contents (HTML / CSS / JavaScript) loaded into any WebViews of this application.
* `javaScriptCanOpenWindowsAutomatically`: Set to `true` to allow JavaScript open windows without user interaction. The default value is `false`.
* `mediaPlaybackRequiresUserGesture`: Set to `true` to prevent HTML5 audio or video from autoplaying. The default value is `true`.
* `minimumFontSize`: Sets the minimum font size. The default value is `8` for Android, `0` for iOS.
* `verticalScrollBarEnabled`: Define whether the vertical scrollbar should be drawn or not. The default value is `true`.
* `horizontalScrollBarEnabled`: Define whether the horizontal scrollbar should be drawn or not. The default value is `true`.
* `resourceCustomSchemes`: List of custom schemes that the WebView must handle. Use the `onLoadResourceCustomScheme` event to intercept resource requests with custom scheme.
* `contentBlockers`: List of `ContentBlocker` that are a set of rules used to block content in the browser window.
* `preferredContentMode`: Sets the content mode that the WebView needs to use when loading and rendering a webpage. The default value is `InAppWebViewUserPreferredContentMode.RECOMMENDED`.
* `useShouldInterceptAjaxRequest`: Set to `true` to be able to listen at the `shouldInterceptAjaxRequest` event. The default value is `false`.
* `useShouldInterceptFetchRequest`: Set to `true` to be able to listen at the `shouldInterceptFetchRequest` event. The default value is `false`.
* `incognito`: Set to `true` to open a browser window with incognito mode. The default value is `false`.
* `cacheEnabled`: Sets whether WebView should use browser caching. The default value is `true`.
* `transparentBackground`: Set to `true` to make the background of the WebView transparent. If your app has a dark theme, this can prevent a white flash on initialization. The default value is `false`.
* `disableVerticalScroll`: Set to `true` to disable vertical scroll. The default value is `false`.
* `disableHorizontalScroll`: Set to `true` to disable horizontal scroll. The default value is `false`.
##### `InAppWebView` Android-specific options
* `textZoom`: Sets the text zoom of the page in percent. The default value is `100`.
* `clearSessionCache`: Set to `true` to have the session cookie cache cleared before the new window is opened.
* `builtInZoomControls`: Set to `true` if the WebView should use its built-in zoom mechanisms. The default value is `false`.
* `displayZoomControls`: Set to `true` if the WebView should display on-screen zoom controls when using the built-in zoom mechanisms. The default value is `false`.
* `supportZoom`: Set to `false` if the WebView should not support zooming using its on-screen zoom controls and gestures. The default value is `true`.
* `databaseEnabled`: Set to `true` if you want the database storage API is enabled. The default value is `false`.
* `domStorageEnabled`: Set to `true` if you want the DOM storage API is enabled. The default value is `false`.
* `useWideViewPort`: Set to `true` if the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport.
* `safeBrowsingEnabled`: Sets whether Safe Browsing is enabled. Safe Browsing allows WebView to protect against malware and phishing attacks by verifying the links.
* `mixedContentMode`: Configures the WebView's behavior when a secure origin attempts to load a resource from an insecure origin.
* `allowContentAccess`: Enables or disables content URL access within WebView. Content URL access allows WebView to load content from a content provider installed in the system. The default value is `true`.
* `allowFileAccess`: Enables or disables file access within WebView. Note that this enables or disables file system access only.
* `allowFileAccessFromFileURLs`: Sets whether JavaScript running in the context of a file scheme URL should be allowed to access content from other file scheme URLs.
* `allowUniversalAccessFromFileURLs`: Sets whether JavaScript running in the context of a file scheme URL should be allowed to access content from any origin.
* `appCachePath`: Sets the path to the Application Caches files. In order for the Application Caches API to be enabled, this option must be set a path to which the application can write.
* `blockNetworkImage`: Sets whether the WebView should not load image resources from the network (resources accessed via http and https URI schemes). The default value is `false`.
* `blockNetworkLoads`: Sets whether the WebView should not load resources from the network. The default value is `false`.
* `cacheMode`: Overrides the way the cache is used. The way the cache is used is based on the navigation type. For a normal page load, the cache is checked and content is re-validated as needed.
* `cursiveFontFamily`: Sets the cursive font family name. The default value is `"cursive"`.
* `defaultFixedFontSize`: Sets the default fixed font size. The default value is `16`.
* `defaultFontSize`: Sets the default font size. The default value is `16`.
* `defaultTextEncodingName`: Sets the default text encoding name to use when decoding html pages. The default value is `"UTF-8"`.
* `disabledActionModeMenuItems`: Disables the action mode menu items according to menuItems flag.
* `fantasyFontFamily`: Sets the fantasy font family name. The default value is `"fantasy"`.
* `fixedFontFamily`: Sets the fixed font family name. The default value is `"monospace"`.
* `forceDark`: Set the force dark mode for this WebView. The default value is `AndroidInAppWebViewForceDark.FORCE_DARK_OFF`.
* `geolocationEnabled`: Sets whether Geolocation API is enabled. The default value is `true`.
* `layoutAlgorithm`: Sets the underlying layout algorithm. This will cause a re-layout of the WebView.
* `loadWithOverviewMode`: Sets whether the WebView loads pages in overview mode, that is, zooms out the content to fit on screen by width.
* `loadsImagesAutomatically`: Sets whether the WebView should load image resources. Note that this method controls loading of all images, including those embedded using the data URI scheme.
* `minimumLogicalFontSize`: Sets the minimum logical font size. The default is `8`.
* `initialScale`: Sets the initial scale for this WebView. 0 means default. The behavior for the default scale depends on the state of `useWideViewPort` and `loadWithOverviewMode`.
* `needInitialFocus`: Tells the WebView whether it needs to set a node. The default value is `true`.
* `offscreenPreRaster`: Sets whether this WebView should raster tiles when it is offscreen but attached to a window.
* `sansSerifFontFamily`: Sets the sans-serif font family name. The default value is `"sans-serif"`.
* `serifFontFamily`: Sets the serif font family name. The default value is `"sans-serif"`.
* `standardFontFamily`: Sets the standard font family name. The default value is `"sans-serif"`.
* `saveFormData`: Sets whether the WebView should save form data. In Android O, the platform has implemented a fully functional Autofill feature to store form data.
* `thirdPartyCookiesEnabled`: Boolean value to enable third party cookies in the WebView.
* `hardwareAcceleration`: Boolean value to enable Hardware Acceleration in the WebView.
##### `InAppWebView` iOS-specific options
* `disallowOverScroll`: Set to `true` to disable the bouncing of the WebView when the scrolling has reached an edge of the content. The default value is `false`.
* `enableViewportScale`: Set to `true` to allow a viewport meta tag to either disable or restrict the range of user scaling. The default value is `false`.
* `suppressesIncrementalRendering`: Set to `true` if you want the WebView suppresses content rendering until it is fully loaded into memory. The default value is `false`.
* `allowsAirPlayForMediaPlayback`: Set to `true` to allow AirPlay. The default value is `true`.
* `allowsBackForwardNavigationGestures`: Set to `true` to allow the horizontal swipe gestures trigger back-forward list navigations. The default value is `true`.
* `allowsLinkPreview`: Set to `true` to allow that pressing on a link displays a preview of the destination for the link. The default value is `true`.
* `ignoresViewportScaleLimits`: Set to `true` if you want that the WebView should always allow scaling of the webpage, regardless of the author's intent.
* `allowsInlineMediaPlayback`: Set to `true` to allow HTML5 media playback to appear inline within the screen layout, using browser-supplied controls rather than native controls.
* `allowsPictureInPictureMediaPlayback`: Set to `true` to allow HTML5 videos play picture-in-picture. The default value is `true`.
* `isFraudulentWebsiteWarningEnabled`: A Boolean value indicating whether warnings should be shown for suspected fraudulent content such as phishing or malware.
* `selectionGranularity`: The level of granularity with which the user can interactively select content in the web view.
* `dataDetectorTypes`: Specifying a dataDetectoryTypes value adds interactivity to web content that matches the value.
* `sharedCookiesEnabled`: Set `true` if shared cookies from `HTTPCookieStorage.shared` should used for every load request in the WebView.
#### `InAppWebView` Events
* `onWebViewCreated`: Event fired when the InAppWebView is created.
* `onLoadStart`: Event fired when the InAppWebView starts to load an url.
* `onLoadStop`: Event fired when the InAppWebView finishes loading an url.
* `onLoadError`: Event fired when the InAppWebView encounters an error loading an url.
* `onLoadHttpError`: vent fires when the InAppWebView main page receives an HTTP error.
* `onProgressChanged`: Event fired when the current progress of loading a page is changed.
* `onConsoleMessage`: Event fired when the InAppWebView receives a ConsoleMessage.
* `shouldOverrideUrlLoading`: Give the host application a chance to take control when a URL is about to be loaded in the current WebView.
* `onLoadResource`: Event fired when the InAppWebView loads a resource.
* `onScrollChanged`: Event fired when the InAppWebView scrolls.
* `onDownloadStart`: Event fired when InAppWebView recognizes and starts a downloadable file.
* `onLoadResourceCustomScheme`: Event fired when the InAppWebView finds the `custom-scheme` while loading a resource. Here you can handle the url request and return a CustomSchemeResponse to load a specific resource encoded to `base64`.
* `onTargetBlank`: Event fired when the InAppWebView tries to open a link with `target="_blank"`.
* `onGeolocationPermissionsShowPrompt`: Event that notifies the host application that web content from the specified origin is attempting to use the Geolocation API, but no permission state is currently set for that origin (available only on Android).
* `onJsAlert`: Event fired when javascript calls the `alert()` method to display an alert dialog.
* `onJsConfirm`: Event fired when javascript calls the `confirm()` method to display a confirm dialog.
* `onJsPrompt`: Event fired when javascript calls the `prompt()` method to display a prompt dialog.
* `onSafeBrowsingHit`: Event fired when the webview notifies that a loading URL has been flagged by Safe Browsing (available only on Android).
* `onReceivedHttpAuthRequest`: Event fired when the WebView received an HTTP authentication request. The default behavior is to cancel the request.
* `onReceivedServerTrustAuthRequest`: Event fired when the WebView need to perform server trust authentication (certificate validation).
* `onReceivedClientCertRequest`: Notify the host application to handle a SSL client certificate request.
* `onFindResultReceived`: Event fired as find-on-page operations progress.
* `shouldInterceptAjaxRequest`: Event fired when an `XMLHttpRequest` is sent to a server.
* `onAjaxReadyStateChange`: Event fired whenever the `readyState` attribute of an `XMLHttpRequest` changes.
* `onAjaxProgress`: Event fired as an `XMLHttpRequest` progress.
* `shouldInterceptFetchRequest`: Event fired when a request is sent to a server through [Fetch API](https://developer.mozilla.org/it/docs/Web/API/Fetch_API).
* `onNavigationStateChange`: Event fired when the navigation state of the InAppWebView changes.
### `InAppBrowser` class
In-App Browser using native WebView.
`inAppBrowser.webViewController` can be used to access the `InAppWebView` API.
......@@ -662,50 +461,29 @@ import 'package:flutter/material.dart';
import 'package:flutter_inappbrowser/flutter_inappbrowser.dart';
class MyInAppBrowser extends InAppBrowser {
@override
void onBrowserCreated() async {
print("\n\nBrowser Ready!\n\n");
Future onBrowserCreated() async {
print("\n\nBrowser Created!\n\n");
}
@override
void onLoadStart(String url) {
Future onLoadStart(String url) async {
print("\n\nStarted $url\n\n");
}
@override
Future onLoadStop(String url) async {
print("\n\nStopped $url\n\n");
// call a javascript message handler
await this.webViewController.injectScriptCode("window.flutter_inappbrowser.callHandler('handlerNameTest', 1, 5,'string', {'key': 5}, [4,6,8]);");
// print body html
print(await this.webViewController.injectScriptCode("document.body.innerHTML"));
// console messages
await this.webViewController.injectScriptCode("console.log({'testObject': 5});"); // the message will be: [object Object]
await this.webViewController.injectScriptCode("console.log('testObjectStringify', JSON.stringify({'testObject': 5}));"); // the message will be: testObjectStringify {"testObject": 5}
await this.webViewController.injectScriptCode("console.error('testError', false);"); // the message will be: testError false
// add jquery library and custom javascript
await this.webViewController.injectScriptFile("https://code.jquery.com/jquery-3.3.1.min.js");
this.webViewController.injectScriptCode("""
\$( "body" ).html( "Next Step..." )
""");
// add custom css
this.webViewController.injectStyleCode("""
body {
background-color: #3c3c3c !important;
}
""");
this.webViewController.injectStyleFile("https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css");
}
@override
void onLoadError(String url, int code, String message) {
print("\n\nCan't load $url.. Error: $message\n\n");
print("Can't load $url.. Error: $message");
}
@override
void onProgressChanged(int progress) {
print("Progress: $progress");
}
@override
......@@ -716,65 +494,60 @@ class MyInAppBrowser extends InAppBrowser {
@override
void shouldOverrideUrlLoading(String url) {
print("\n\n override $url\n\n");
this.webViewController.loadUrl(url);
this.webViewController.loadUrl(url: url);
}
@override
void onLoadResource(WebResourceResponse response, WebResourceRequest request) {
print("Started at: " + response.startTime.toString() + "ms ---> duration: " + response.duration.toString() + "ms " + response.url);
void onLoadResource(LoadedResource response) {
print("Started at: " +
response.startTime.toString() +
"ms ---> duration: " +
response.duration.toString() +
"ms " +
response.url);
}
@override
void onConsoleMessage(ConsoleMessage consoleMessage) {
print("""
console output:
sourceURL: ${consoleMessage.sourceURL}
lineNumber: ${consoleMessage.lineNumber}
message: ${consoleMessage.message}
messageLevel: ${consoleMessage.messageLevel}
""");
messageLevel: ${consoleMessage.messageLevel.toValue()}
""");
}
}
MyInAppBrowser inAppBrowser = new MyInAppBrowser();
void main() => runApp(new MyApp());
class MyApp extends StatefulWidget {
final MyInAppBrowser browser = new MyInAppBrowser();
@override
_MyAppState createState() => new _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
// listen for post messages coming from the JavaScript side
inAppBrowser.webViewController.addJavaScriptHandler("handlerNameTest", (arguments) async {
print("handlerNameTest arguments");
print(arguments); // it prints: [1, 5, string, {key: 5}, [4, 6, 8]]
});
}
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
title: const Text('Flutter InAppBrowser Plugin example app'),
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('InAppBrowser Example'),
),
body: new Center(
child: new RaisedButton(onPressed: () async {
await inAppBrowser.open(url: "https://flutter.io/", options: {
"useShouldOverrideUrlLoading": true,
"useOnLoadResource": true
});
},
child: Text("Open InAppBrowser")
),
body: Center(
child: RaisedButton(
onPressed: () {
widget.browser.openFile(
assetFilePath: "assets/index.html",
options: InAppBrowserClassOptions(
inAppWebViewWidgetOptions: InAppWebViewWidgetOptions(
inAppWebViewOptions: InAppWebViewOptions(
useShouldOverrideUrlLoading: true,
useOnLoadResource: true,
))));
},
child: Text("Open InAppBrowser")),
),
),
);
......@@ -791,282 +564,60 @@ Screenshots:
![android](https://user-images.githubusercontent.com/5956938/45934080-26ffcd00-bf99-11e8-8136-d39a81bd83e7.gif)
#### Future\<void\> InAppBrowser.open
Opens an `url` in a new `InAppBrowser` instance.
- `url`: The `url` to load. Call `encodeUriComponent()` on this if the `url` contains Unicode characters. The default value is `about:blank`.
- `headers`: The additional headers to be used in the HTTP request for this URL, specified as a map from name to value.
- `options`: Options for the `InAppBrowser`.
All platforms support:
- __useShouldOverrideUrlLoading__: Set to `true` to be able to listen at the `shouldOverrideUrlLoading()` event. The default value is `false`.
- __useOnLoadResource__: Set to `true` to be able to listen at the `onLoadResource()` event. The default value is `false`.
- __clearCache__: Set to `true` to have all the browser's cache cleared before the new window is opened. The default value is `false`.
- __userAgent__: Set the custom WebView's user-agent.
- __javaScriptEnabled__: Set to `true` to enable JavaScript. The default value is `true`.
- __javaScriptCanOpenWindowsAutomatically__: Set to `true` to allow JavaScript open windows without user interaction. The default value is `false`.
- __hidden__: Set to `true` to create the browser and load the page, but not show it. The `onLoadStop` event fires when loading is complete. Omit or set to `false` (default) to have the browser open and load normally.
- __toolbarTop__: Set to `false` to hide the toolbar at the top of the WebView. The default value is `true`.
- __toolbarTopBackgroundColor__: Set the custom background color of the toolbar at the top.
- __hideUrlBar__: Set to `true` to hide the url bar on the toolbar at the top. The default value is `false`.
- __mediaPlaybackRequiresUserGesture__: Set to `true` to prevent HTML5 audio or video from autoplaying. The default value is `true`.
**Android** supports these additional options:
- __hideTitleBar__: Set to `true` if you want the title should be displayed. The default value is `false`.
- __closeOnCannotGoBack__: Set to `false` to not close the InAppBrowser when the user click on the back button and the WebView cannot go back to the history. The default value is `true`.
- __clearSessionCache__: Set to `true` to have the session cookie cache cleared before the new window is opened.
- __builtInZoomControls__: Set to `true` if the WebView should use its built-in zoom mechanisms. The default value is `false`.
- __displayZoomControls__: Set to `true` if the WebView should display on-screen zoom controls when using the built-in zoom mechanisms. The default value is `false`.
- __supportZoom__: Set to `false` if the WebView should not support zooming using its on-screen zoom controls and gestures. The default value is `true`.
- __databaseEnabled__: Set to `true` if you want the database storage API is enabled. The default value is `false`.
- __domStorageEnabled__: Set to `true` if you want the DOM storage API is enabled. The default value is `false`.
- __useWideViewPort__: Set to `true` if the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport. When the value of the setting is false, the layout width is always set to the width of the WebView control in device-independent (CSS) pixels. When the value is true and the page contains the viewport meta tag, the value of the width specified in the tag is used. If the page does not contain the tag or does not provide a width, then a wide viewport will be used. The default value is `true`.
- __safeBrowsingEnabled__: Set to `true` if you want the Safe Browsing is enabled. Safe Browsing allows WebView to protect against malware and phishing attacks by verifying the links. The default value is `true`.
- __progressBar__: Set to `false` to hide the progress bar at the bottom of the toolbar at the top. The default value is `true`.
- __textZoom__: Set text scaling of the WebView. The default value is `100`.
- __mixedContentMode__: Configures the WebView's behavior when a secure origin attempts to load a resource from an insecure origin. By default, apps that target `Build.VERSION_CODES.KITKAT` or below default to `MIXED_CONTENT_ALWAYS_ALLOW`. Apps targeting `Build.VERSION_CODES.LOLLIPOP` default to `MIXED_CONTENT_NEVER_ALLOW`. The preferred and most secure mode of operation for the WebView is `MIXED_CONTENT_NEVER_ALLOW` and use of `MIXED_CONTENT_ALWAYS_ALLOW` is strongly discouraged.
**iOS** supports these additional options:
- __disallowOverScroll__: Set to `true` to disable the bouncing of the WebView when the scrolling has reached an edge of the content. The default value is `false`.
- __toolbarBottom__: Set to `false` to hide the toolbar at the bottom of the WebView. The default value is `true`.
- __toolbarBottomBackgroundColor__: Set the custom background color of the toolbar at the bottom.
- __toolbarBottomTranslucent__: Set to `true` to set the toolbar at the bottom translucent. The default value is `true`.
- __closeButtonCaption__: Set the custom text for the close button.
- __closeButtonColor__: Set the custom color for the close button.
- __presentationStyle__: Set the custom modal presentation style when presenting the WebView. The default value is `0 //fullscreen`. See [UIModalPresentationStyle](https://developer.apple.com/documentation/uikit/uimodalpresentationstyle) for all the available styles.
- __transitionStyle__: Set to the custom transition style when presenting the WebView. The default value is `0 //crossDissolve`. See [UIModalTransitionStyle](https://developer.apple.com/documentation/uikit/uimodaltransitionStyle) for all the available styles.
- __enableViewportScale__: Set to `true` to allow a viewport meta tag to either disable or restrict the range of user scaling. The default value is `false`.
- __suppressesIncrementalRendering__: Set to `true` if you want the WebView suppresses content rendering until it is fully loaded into memory.. The default value is `false`.
- __allowsAirPlayForMediaPlayback__: Set to `true` to allow AirPlay. The default value is `true`.
- __allowsBackForwardNavigationGestures__: Set to `true` to allow the horizontal swipe gestures trigger back-forward list navigations. The default value is `true`.
- __allowsLinkPreview__: Set to `true` to allow that pressing on a link displays a preview of the destination for the link. The default value is `true`.
- __ignoresViewportScaleLimits__: Set to `true` if you want that the WebView should always allow scaling of the webpage, regardless of the author's intent. The ignoresViewportScaleLimits property overrides the `user-scalable` HTML property in a webpage. The default value is `false`.
- __allowsInlineMediaPlayback__: Set to `true` to allow HTML5 media playback to appear inline within the screen layout, using browser-supplied controls rather than native controls. For this to work, add the `webkit-playsinline` attribute to any `<video>` elements. The default value is `false`.
- __allowsPictureInPictureMediaPlayback__: Set to `true` to allow HTML5 videos play picture-in-picture. The default value is `true`.
- __spinner__: Set to `false` to hide the spinner when the WebView is loading a page. The default value is `true`.
Example:
```dart
inAppBrowser.open('https://flutter.io/', options: {
"useShouldOverrideUrlLoading": true,
"useOnLoadResource": true,
"clearCache": true,
"disallowOverScroll": true,
"domStorageEnabled": true,
"supportZoom": false,
"toolbarBottomTranslucent": false,
"allowsLinkPreview": false
});
```
```dart
inAppBrowser.open({String url = "about:blank", Map<String, String> headers = const {}, Map<String, dynamic> options = const {}});
```
#### Future\<void\> InAppBrowser.openFile
Opens the given `assetFilePath` file in a new `InAppBrowser` instance. The other arguments are the same of `InAppBrowser.open()`.
To be able to load your local files (assets, js, css, etc.), you need to add them in the `assets` section of the `pubspec.yaml` file, otherwise they cannot be found!
Example of a `pubspec.yaml` file:
```yaml
...
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
assets:
- assets/index.html
- assets/css/
- assets/images/
...
```
Example of a `main.dart` file:
```dart
...
inAppBrowser.openFile("assets/index.html");
...
```
```dart
inAppBrowser.openFile(String assetFilePath, {Map<String, String> headers = const {}, Map<String, dynamic> options = const {}});
```
#### static Future\<void\> InAppBrowser.openData
Opens a new `InAppBrowser` instance with `data` as a content, using `baseUrl` as the base URL for it.
The `mimeType` parameter specifies the format of the data.
The `encoding` parameter specifies the encoding of the data.
```dart
InAppBrowser.openData(String data, {String mimeType = "text/html", String encoding = "utf8", String baseUrl = "about:blank", Map<String, dynamic> options = const {}});
```
#### static Future\<void\> InAppBrowser.openWithSystemBrowser
#### `InAppBrowser` Methods
This is a static method that opens an `url` in the system browser. You wont be able to use the `InAppBrowser` methods here!
* `open({String url = "about:blank", Map<String, String> headers = const {}, InAppBrowserClassOptions options})`: Opens an `url` in a new `InAppBrowser` instance.
* `openFile({@required String assetFilePath, Map<String, String> headers = const {}, InAppBrowserClassOptions options})`: Opens the given `assetFilePath` file in a new `InAppBrowser` instance. The other arguments are the same of `InAppBrowser.open`.
* `openData({@required String data, String mimeType = "text/html", String encoding = "utf8", String baseUrl = "about:blank", InAppBrowserClassOptions options})`: Opens a new `InAppBrowser` instance with `data` as a content, using `baseUrl` as the base URL for it.
* `openWithSystemBrowser({@required String url})`: This is a static method that opens an `url` in the system browser. You wont be able to use the `InAppBrowser` methods here!
* `show`: Displays an `InAppBrowser` window that was opened hidden. Calling this has no effect if the `InAppBrowser` was already visible.
* `hide`: Hides the `InAppBrowser` window. Calling this has no effect if the `InAppBrowser` was already hidden.
* `close`: Closes the `InAppBrowser` window.
* `isHidden`: Check if the Web View of the `InAppBrowser` instance is hidden.
* `setOptions({@required InAppBrowserClassOptions options})`: Sets the `InAppBrowser` options with the new `options` and evaluates them.
* `getOptions`: Gets the current `InAppBrowser` options as a `Map`. Returns `null` if the options are not setted yet.
* `isOpened`: Returns `true` if the `InAppBrowser` instance is opened, otherwise `false`.
```dart
InAppBrowser.openWithSystemBrowser(String url);
```
#### `InAppBrowser` options
#### Future\<void\> InAppBrowser.show
They are the same of the `InAppWebView` class.
Specific options of the `InAppBrowser` class are:
Displays an `InAppBrowser` window that was opened hidden. Calling this has no effect if the `InAppBrowser` was already visible.
##### `InAppBrowser` Cross-platform options
```dart
inAppBrowser.show();
```
* `hidden`: Set to `true` to create the browser and load the page, but not show it. Omit or set to `false` to have the browser open and load normally. The default value is `false`.
* `toolbarTop`: Set to `false` to hide the toolbar at the top of the WebView. The default value is `true`.
* `toolbarTopBackgroundColor`: Set the custom background color of the toolbar at the top.
* `hideUrlBar`: Set to `true` to hide the url bar on the toolbar at the top. The default value is `false`.
#### Future\<void\> InAppBrowser.hide
##### `InAppBrowser` Android-specific options
Hides the `InAppBrowser` window. Calling this has no effect if the `InAppBrowser` was already hidden.
* `hideTitleBar`: Set to `true` if you want the title should be displayed. The default value is `false`.
* `toolbarTopFixedTitle`: Set the action bar's title.
* `closeOnCannotGoBack`: Set to `false` to not close the InAppBrowser when the user click on the back button and the WebView cannot go back to the history. The default value is `true`.
* `progressBar`: Set to `false` to hide the progress bar at the bottom of the toolbar at the top. The default value is `true`.
```dart
inAppBrowser.hide();
```
##### `InAppBrowser` iOS-specific options
#### Future\<void\> InAppBrowser.close
* `toolbarBottom`: Set to `false` to hide the toolbar at the bottom of the WebView. The default value is `true`.
* `toolbarBottomBackgroundColor`: Set the custom background color of the toolbar at the bottom.
* `toolbarBottomTranslucent`: Set to `true` to set the toolbar at the bottom translucent. The default value is `true`.
* `closeButtonCaption`: Set the custom text for the close button.
* `closeButtonColor`: Set the custom color for the close button.
* `presentationStyle`: Set the custom modal presentation style when presenting the WebView. The default value is `IosWebViewOptionsPresentationStyle.FULL_SCREEN`.
* `transitionStyle`: Set to the custom transition style when presenting the WebView. The default value is `IosWebViewOptionsTransitionStyle.COVER_VERTICAL`.
* `spinner`: Set to `false` to hide the spinner when the WebView is loading a page. The default value is `true`.
Closes the `InAppBrowser` window.
#### `InAppBrowser` Events
```dart
inAppBrowser.close();
```
They are the same of the `InAppWebView` class, except for `InAppWebView.onWebViewCreated` event.
Specific events of the `InAppBrowser` class are:
#### Future\<bool\> InAppBrowser.isHidden
Check if the Web View of the `InAppBrowser` instance is hidden.
```dart
inAppBrowser.isHidden();
```
#### Future\<void\> InAppBrowser.setOptions
Sets the `InAppBrowser` options and the `InAppWebView` options with the new `options` and evaluates them.
```dart
inAppBrowser.setOptions(Map<String, dynamic> options);
```
#### Future\<Map\<String, dynamic\>\> InAppBrowser.getOptions
Gets the current `InAppBrowser` options and the current `InAppWebView` options merged together. Returns `null` if the options are not setted yet.
```dart
inAppBrowser.getOptions();
```
#### bool InAppBrowser.isOpened
Returns `true` if the `InAppBrowser` instance is opened, otherwise `false`.
```dart
inAppBrowser.isOpened();
```
#### Events
Event `onBrowserCreated` fires when the `InAppBrowser` is created.
```dart
@override
void onBrowserCreated() {
}
```
Event `onLoadStart` fires when the `InAppBrowser` starts to load an `url`.
```dart
@override
void onLoadStart(String url) {
}
```
Event `onLoadStop` fires when the `InAppBrowser` finishes loading an `url`.
```dart
@override
void onLoadStop(String url) {
}
```
Event `onLoadError` fires when the `InAppBrowser` encounters an error loading an `url`.
```dart
@override
void onLoadError(String url, int code, String message) {
}
```
Event `onProgressChanged` fires when the current `progress` (range 0-100) of loading a page is changed.
```dart
@override
void onProgressChanged(int progress) {
}
```
Event `onExit` fires when the `InAppBrowser` window is closed.
```dart
@override
void onExit() {
}
```
Event `onConsoleMessage` fires when the `InAppBrowser` webview receives a `ConsoleMessage`.
```dart
@override
void onConsoleMessage(ConsoleMessage consoleMessage) {
}
```
`shouldOverrideUrlLoading`: Give the host application a chance to take control when a URL is about to be loaded in the current WebView.
**NOTE**: In order to be able to listen this event, you need to set `useShouldOverrideUrlLoading` option to `true`.
```dart
@override
void shouldOverrideUrlLoading(String url) {
}
```
Event `onLoadResource` fires when the `InAppBrowser` webview loads a resource.
**NOTE**: In order to be able to listen this event, you need to set `useOnLoadResource` option to `true`.
**NOTE only for iOS**: In some cases, the `response.data` of a `response` with `text/html` encoding could be empty.
```dart
@override
void onLoadResource(WebResourceResponse response, WebResourceRequest request) {
}
```
Event `onScrollChanged` fires when the `InAppBrowser` webview scrolls.
`x` represents the current horizontal scroll origin in pixels.
`y` represents the current vertical scroll origin in pixels.
```dart
@override
void onScrollChanged(int x, int y) {
}
```
* `onBrowserCreated`: Event fired when the `InAppBrowser` is created.
* `onExit`: Event fired when the `InAppBrowser` window is closed.
### `ChromeSafariBrowser` class
[Chrome Custom Tabs](https://developer.android.com/reference/android/support/customtabs/package-summary) on Android / [SFSafariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller) on iOS.
You can initialize the `ChromeSafariBrowser` instance with an `InAppBrowser` fallback instance.
......@@ -1100,11 +651,9 @@ class MyInAppBrowser extends InAppBrowser {
}
MyInAppBrowser inAppBrowserFallback = new MyInAppBrowser();
class MyChromeSafariBrowser extends ChromeSafariBrowser {
MyChromeSafariBrowser(browserFallback) : super(browserFallback);
MyChromeSafariBrowser(browserFallback) : super(bFallback: browserFallback);
@override
void onOpened() {
......@@ -1122,12 +671,11 @@ class MyChromeSafariBrowser extends ChromeSafariBrowser {
}
}
MyChromeSafariBrowser chromeSafariBrowser = new MyChromeSafariBrowser(inAppBrowserFallback);
void main() => runApp(new MyApp());
class MyApp extends StatefulWidget {
final ChromeSafariBrowser browser = new MyChromeSafariBrowser(new MyInAppBrowser());
@override
_MyAppState createState() => new _MyAppState();
}
......@@ -1141,26 +689,21 @@ class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
title: const Text('Flutter InAppBrowser Plugin example app'),
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('ChromeSafariBrowser Example'),
),
body: new Center(
child: new RaisedButton(onPressed: () {
chromeSafariBrowser.open("https://flutter.io/", options: {
"addShareButton": false,
"toolbarBackgroundColor": "#000000",
"dismissButtonStyle": 1,
"preferredBarTintColor": "#000000",
},
optionsFallback: {
"toolbarTopBackgroundColor": "#000000",
"closeButtonCaption": "Close"
});
},
child: Text("Open ChromeSafariBrowser")
),
body: Center(
child: RaisedButton(
onPressed: () async {
await widget.browser.open(
url: "https://flutter.dev/",
options: ChromeSafariBrowserClassOptions(
androidChromeCustomTabsOptions: AndroidChromeCustomTabsOptions(addShareButton: false),
iosSafariOptions: IosSafariOptions(barCollapsingEnabled: true)));
},
child: Text("Open Chrome Safari Browser")),
),
),
);
......@@ -1178,72 +721,39 @@ Screenshots:
![android](https://user-images.githubusercontent.com/5956938/46532149-0c362e00-c8a0-11e8-8134-9af18f38a746.gif)
#### Future\<void\> ChromeSafariBrowser.open
Opens an `url` in a new `ChromeSafariBrowser` instance.
#### `ChromeSafariBrowser` Methods
- `url`: The `url` to load. Call `encodeUriComponent()` on this if the `url` contains Unicode characters.
* `open({@required String url, ChromeSafariBrowserClassOptions options, Map<String, String> headersFallback = const {}, InAppBrowserClassOptions optionsFallback})`: Opens an `url` in a new `ChromeSafariBrowser` instance.
* `isOpened`: Returns `true` if the `ChromeSafariBrowser` instance is opened, otherwise `false`.
- `options`: Options for the `ChromeSafariBrowser`.
#### `ChromeSafariBrowser` options
- `headersFallback`: The additional header of the `InAppBrowser` instance fallback to be used in the HTTP request for this URL, specified as a map from name to value.
##### `ChromeSafariBrowser` Android-specific options
- `optionsFallback`: Options used by the `InAppBrowser` instance fallback.
* `addShareButton`: Set to `false` if you don't want the default share button. The default value is `true`.
* `showTitle`: Set to `false` if the title shouldn't be shown in the custom tab. The default value is `true`.
* `toolbarBackgroundColor`: Set the custom background color of the toolbar.
* `enableUrlBarHiding`: Set to `true` to enable the url bar to hide as the user scrolls down on the page. The default value is `false`.
* `instantAppsEnabled`: Set to `true` to enable Instant Apps. The default value is `false`.
**Android** supports these options:
##### `ChromeSafariBrowser` iOS-specific options
- __addShareButton__: Set to `false` if you don't want the default share button. The default value is `true`.
- __showTitle__: Set to `false` if the title shouldn't be shown in the custom tab. The default value is `true`.
- __toolbarBackgroundColor__: Set the custom background color of the toolbar.
- __enableUrlBarHiding__: Set to `true` to enable the url bar to hide as the user scrolls down on the page. The default value is `false`.
- __instantAppsEnabled__: Set to `true` to enable Instant Apps. The default value is `false`.
* `entersReaderIfAvailable`: Set to `true` if Reader mode should be entered automatically when it is available for the webpage. The default value is `false`.
* `barCollapsingEnabled`: Set to `true` to enable bar collapsing. The default value is `false`.
* `dismissButtonStyle`: Set the custom style for the dismiss button. The default value is `IosSafariOptionsDismissButtonStyle.DONE`.
* `preferredBarTintColor`: Set the custom background color of the navigation bar and the toolbar.
* `preferredControlTintColor`: Set the custom color of the control buttons on the navigation bar and the toolbar.
* `presentationStyle`: Set the custom modal presentation style when presenting the WebView. The default value is `IosWebViewOptionsPresentationStyle.FULL_SCREEN`.
* `transitionStyle`: Set to the custom transition style when presenting the WebView. The default value is `IosWebViewOptionsTransitionStyle.COVER_VERTICAL`.
**iOS** supports these options:
#### `ChromeSafariBrowser` Events
- __entersReaderIfAvailable__: Set to `true` if Reader mode should be entered automatically when it is available for the webpage. The default value is `false`.
- __barCollapsingEnabled__: Set to `true` to enable bar collapsing. The default value is `false`.
- __dismissButtonStyle__: Set the custom style for the dismiss button. The default value is `0 //done`. See [SFSafariViewController.DismissButtonStyle](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/dismissbuttonstyle) for all the available styles.
- __preferredBarTintColor__: Set the custom background color of the navigation bar and the toolbar.
- __preferredControlTintColor__: Set the custom color of the control buttons on the navigation bar and the toolbar.
- __presentationStyle__: Set the custom modal presentation style when presenting the WebView. The default value is `0 //fullscreen`. See [UIModalPresentationStyle](https://developer.apple.com/documentation/uikit/uimodalpresentationstyle) for all the available styles.
- __transitionStyle__: Set to the custom transition style when presenting the WebView. The default value is `0 //crossDissolve`. See [UIModalTransitionStyle](https://developer.apple.com/documentation/uikit/uimodaltransitionStyle) for all the available styles.
Example:
```dart
chromeSafariBrowser.open("https://flutter.io/", options: {
"addShareButton": false,
"toolbarBackgroundColor": "#000000",
"dismissButtonStyle": 1,
"preferredBarTintColor": "#000000",
});
```
#### Events
Event `onOpened` fires when the `ChromeSafariBrowser` is opened.
```dart
@override
void onOpened() {
}
```
Event `onLoaded` fires when the `ChromeSafariBrowser` is loaded.
```dart
@override
void onLoaded() {
}
```
Event `onClosed` fires when the `ChromeSafariBrowser` is closed.
```dart
@override
void onClosed() {
}
```
* `onOpened`: Event fires when the `ChromeSafariBrowser` is opened.
* `onLoaded`: Event fires when the `ChromeSafariBrowser` is loaded.
* `onClosed`: Event fires when the `ChromeSafariBrowser` is closed.
### `InAppLocalhostServer` class
This class allows you to create a simple server on `http://localhost:[port]/` in order to be able to load your assets file on a server. The default `port` value is `8080`.
Example:
......@@ -1261,20 +771,36 @@ Future main() async {
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
title: const Text('Flutter InAppBrowser Plugin example app'),
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('InAppWebView Example'),
),
body: new Center(
child: new RaisedButton(
onPressed: () async {
await inAppBrowser.open(
url: "http://localhost:8080/assets/index.html",
options: {});
},
child: Text("Open InAppBrowser")
),
body: Container(
child: Column(children: <Widget>[
Expanded(
child: Container(
child: InAppWebView(
initialUrl: "http://localhost:8080/assets/index.html",
initialHeaders: {},
initialOptions: InAppWebViewWidgetOptions(
inAppWebViewOptions: InAppWebViewOptions(
debuggingEnabled: true,
)
),
onWebViewCreated: (InAppWebViewController controller) {
},
onLoadStart: (InAppWebViewController controller, String url) {
},
onLoadStop: (InAppWebViewController controller, String url) {
},
),
),
)]
)
),
),
);
......@@ -1284,95 +810,39 @@ Future main() async {
```
#### Future\<void\> InAppLocalhostServer.start
Starts a server on `http://localhost:[port]/`.
**NOTE for iOS**: For the iOS Platform, you need to add the `NSAllowsLocalNetworking` key with `true` in the `Info.plist` file (See [ATS Configuration Basics](https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW35)):
```xml
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsLocalNetworking</key>
<true/>
</dict>
```
The `NSAllowsLocalNetworking` key is available since **iOS 10**.
```dart
localhostServer.start();
```
#### Future\<void\> InAppLocalhostServer.close
Closes the server.
#### `InAppLocalhostServer` methods
```dart
localhostServer.close();
```
* `start`: Starts a server on `http://localhost:[port]/`.
* `close`: Closes the server.
### `CookieManager` class
Manages the cookies used by WebView instances.
**NOTE for iOS**: available from iOS 11.0+.
Example:
```dart
var url = "https://flutter.io/";
await CookieManager.setCookie(url, "myCookie", "cookieValue", domain: "flutter.io", expiresDate: 1540838864611);
print(await CookieManager.getCookies(url));
print(await CookieManager.getCookie(url, "myCookie"));
await CookieManager.deleteCookie(url, "myCookie");
await CookieManager.deleteCookie(url, "_gid", domain: ".googleblog.com");
await CookieManager.deleteCookies(url);
await CookieManager.deleteAllCookies();
```
#### static Future\<void\> CookieManager.setCookie
Sets a cookie for the given `url`. Any existing cookie with the same `host`, `path` and `name` will be replaced with the new cookie.
The cookie being set will be ignored if it is expired.
The default value of `path` is `"/"`.
If `domain` is `null`, its default value will be the domain name of `url`.
```dart
CookieManager.setCookie(String url, String name, String value, { String domain, String path = "/", int expiresDate, int maxAge, bool isSecure });
```
#### static Future\<void\> CookieManager.getCookies
This class implements a singleton object (shared instance) which manages the cookies used by WebView instances.
Gets all the cookies for the given `url`.
```dart
CookieManager.getCookies(String url);
```
#### static Future\<void\> CookieManager.getCookie
Gets a cookie by its `name` for the given `url`.
```dart
CookieManager.getCookie(String url, String name);
```
#### static Future\<void\> CookieManager.deleteCookie
Removes a cookie by its `name` for the given `url`, `domain` and `path`.
**NOTE for iOS**: available from iOS 11.0+.
The default value of `path` is `"/"`.
If `domain` is `null` or empty, its default value will be the domain name of `url`.
```dart
CookieManager.deleteCookie(String url, String name, {String domain = "", String path = "/"});
```
#### `CookieManager` methods
#### static Future\<void\> CookieManager.deleteCookies
* `instance`: Gets the cookie manager shared instance.
* `setCookie({@required String url, @required String name, @required String value, String domain, String path = "/", int expiresDate, int maxAge, bool isSecure })`: Sets a cookie for the given `url`. Any existing cookie with the same `host`, `path` and `name` will be replaced with the new cookie. The cookie being set will be ignored if it is expired.
* `getCookies({@required String url})`: Gets all the cookies for the given `url`.
* `getCookie({@required String url, @required String name})`: Gets a cookie by its `name` for the given `url`.
* `deleteCookie({@required String url, @required String name, String domain = "", String path = "/"})`: Removes a cookie by its `name` for the given `url`, `domain` and `path`.
* `deleteCookies({@required String url, String domain = "", String path = "/"})`: Removes all cookies for the given `url`, `domain` and `path`.
* `deleteAllCookies()`: Removes all cookies.
Removes all cookies for the given `url`, `domain` and `path`.
### `HttpAuthCredentialDatabase` class
The default value of `path` is `"/"`.
If `domain` is `null` or empty, its default value will be the domain name of `url`.
```dart
CookieManager.deleteCookies(String url, {String domain = "", String path = "/"});
```
This class implements a singleton object (shared instance) which manages the shared HTTP auth credentials cache.
On iOS, this class uses the [URLCredentialStorage](https://developer.apple.com/documentation/foundation/urlcredentialstorage) class.
On Android, this class has a custom implementation using `android.database.sqlite.SQLiteDatabase` because [WebViewDatabase](https://developer.android.com/reference/android/webkit/WebViewDatabase) doesn't offer the same functionalities as iOS `URLCredentialStorage`.
#### static Future\<void\> CookieManager.deleteAllCookies
#### `HttpAuthCredentialDatabase` methods
Removes all cookies.
```dart
CookieManager.deleteAllCookies();
```
* `instance`: Gets the database shared instance.
* `getAllAuthCredentials`: Gets a map list of all HTTP auth credentials saved.
* `getHttpAuthCredentials({@required ProtectionSpace protectionSpace})`: Gets all the HTTP auth credentials saved for that `protectionSpace`.
* `setHttpAuthCredential({@required ProtectionSpace protectionSpace, @required HttpAuthCredential credential})`: Saves an HTTP auth `credential` for that `protectionSpace`.
* `removeHttpAuthCredential({@required ProtectionSpace protectionSpace, @required HttpAuthCredential credential})`: Removes an HTTP auth `credential` for that `protectionSpace`.
* `removeHttpAuthCredentials({@required ProtectionSpace protectionSpace})`: Removes all the HTTP auth credentials saved for that `protectionSpace`.
* `clearAllAuthCredentials()`: Removes all the HTTP auth credentials saved in the database.
......@@ -14,8 +14,6 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
String url = "";
double progress = 0;
TextEditingController _textFieldController = TextEditingController();
@override
void initState() {
super.initState();
......@@ -24,93 +22,91 @@ class _InAppWebViewExampleScreenState extends State<InAppWebViewExampleScreen> {
@override
void dispose() {
super.dispose();
_textFieldController.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
"InAppWebView",
)),
title: Text("InAppWebView")
),
drawer: myDrawer(context: context),
body: Container(
child: Column(children: <Widget>[
Container(
padding: EdgeInsets.all(20.0),
child: Text(
"CURRENT URL\n${(url.length > 50) ? url.substring(0, 50) + "..." : url}"),
),
Container(
padding: EdgeInsets.all(10.0),
child: progress < 1.0
? LinearProgressIndicator(value: progress)
: Container()),
Expanded(
child: Container(
margin: const EdgeInsets.all(10.0),
decoration:
BoxDecoration(border: Border.all(color: Colors.blueAccent)),
child: InAppWebView(
initialUrl: "https://flutter.dev/",
initialHeaders: {},
initialOptions: InAppWebViewWidgetOptions(
inAppWebViewOptions: InAppWebViewOptions(
debuggingEnabled: true,
clearCache: true
)
),
onWebViewCreated: (InAppWebViewController controller) {
webView = controller;
},
onLoadStart: (InAppWebViewController controller, String url) {
setState(() {
this.url = url;
});
},
onLoadStop: (InAppWebViewController controller, String url) async {
setState(() {
this.url = url;
});
},
onProgressChanged: (InAppWebViewController controller, int progress) {
setState(() {
this.progress = progress / 100;
});
},
child: Column(children: <Widget>[
Container(
padding: EdgeInsets.all(20.0),
child: Text(
"CURRENT URL\n${(url.length > 50) ? url.substring(0, 50) + "..." : url}"),
),
Container(
padding: EdgeInsets.all(10.0),
child: progress < 1.0
? LinearProgressIndicator(value: progress)
: Container()),
Expanded(
child: Container(
margin: const EdgeInsets.all(10.0),
decoration:
BoxDecoration(border: Border.all(color: Colors.blueAccent)),
child: InAppWebView(
initialUrl: "https://flutter.dev/",
initialHeaders: {},
initialOptions: InAppWebViewWidgetOptions(
inAppWebViewOptions: InAppWebViewOptions(
debuggingEnabled: true,
)
),
onWebViewCreated: (InAppWebViewController controller) {
webView = controller;
},
onLoadStart: (InAppWebViewController controller, String url) {
setState(() {
this.url = url;
});
},
onLoadStop: (InAppWebViewController controller, String url) async {
setState(() {
this.url = url;
});
},
onProgressChanged: (InAppWebViewController controller, int progress) {
setState(() {
this.progress = progress / 100;
});
},
),
),
ButtonBar(
alignment: MainAxisAlignment.center,
children: <Widget>[
RaisedButton(
child: Icon(Icons.arrow_back),
onPressed: () {
if (webView != null) {
webView.goBack();
}
},
),
RaisedButton(
child: Icon(Icons.arrow_forward),
onPressed: () {
if (webView != null) {
webView.goForward();
}
},
),
RaisedButton(
child: Icon(Icons.refresh),
onPressed: () {
if (webView != null) {
webView.reload();
}
},
),
],
),
])));
),
ButtonBar(
alignment: MainAxisAlignment.center,
children: <Widget>[
RaisedButton(
child: Icon(Icons.arrow_back),
onPressed: () {
if (webView != null) {
webView.goBack();
}
},
),
RaisedButton(
child: Icon(Icons.arrow_forward),
onPressed: () {
if (webView != null) {
webView.goForward();
}
},
),
RaisedButton(
child: Icon(Icons.refresh),
onPressed: () {
if (webView != null) {
webView.reload();
}
},
),
],
),
]))
);
}
}
......@@ -42,7 +42,6 @@ flutter:
uses-material-design: true
assets:
- assets/certificate.pfx
- assets/index.html
- assets/page-1.html
- assets/page-2.html
......
......@@ -105,6 +105,7 @@ class ChromeSafariBrowser {
}
///Returns `true` if the [ChromeSafariBrowser] instance is opened, otherwise `false`.
bool isOpened() {
return this._isOpened;
}
......
......@@ -5,13 +5,14 @@ import 'package:flutter/services.dart';
import 'types.dart';
///Manages the cookies used by WebView instances.
///CookieManager class implements a singleton object (shared instance) which manages the cookies used by WebView instances.
///
///**NOTE for iOS**: available from iOS 11.0+.
class CookieManager {
static CookieManager _instance;
static const MethodChannel _channel = const MethodChannel('com.pichillilorenzo/flutter_inappbrowser_cookiemanager');
///Gets the cookie manager shared instance.
static CookieManager instance() {
return (_instance != null) ? _instance : _init();
}
......
......@@ -281,27 +281,32 @@ class InAppBrowser {
return this._isOpened;
}
///Event fires when the [InAppBrowser] is created.
///Event fired when the [InAppBrowser] is created.
void onBrowserCreated() {
}
///Event fires when the [InAppBrowser] starts to load an [url].
///Event fired when the [InAppBrowser] window is closed.
void onExit() {
}
///Event fired when the [InAppBrowser] starts to load an [url].
void onLoadStart(String url) {
}
///Event fires when the [InAppBrowser] finishes loading an [url].
///Event fired when the [InAppBrowser] finishes loading an [url].
void onLoadStop(String url) {
}
///Event fires when the [InAppBrowser] encounters an error loading an [url].
///Event fired when the [InAppBrowser] encounters an error loading an [url].
void onLoadError(String url, int code, String message) {
}
///Event fires when the [InAppBrowser] main page receives an HTTP error.
///Event fired when the [InAppBrowser] main page receives an HTTP error.
///
///[url] represents the url of the main page that received the HTTP error.
///
......@@ -314,17 +319,12 @@ class InAppBrowser {
}
///Event fires when the current [progress] (range 0-100) of loading a page is changed.
///Event fired when the current [progress] (range 0-100) of loading a page is changed.
void onProgressChanged(int progress) {
}
///Event fires when the [InAppBrowser] window is closed.
void onExit() {
}
///Event fires when the [InAppBrowser] webview receives a [ConsoleMessage].
///Event fired when the [InAppBrowser] webview receives a [ConsoleMessage].
void onConsoleMessage(ConsoleMessage consoleMessage) {
}
......@@ -336,14 +336,14 @@ class InAppBrowser {
}
///Event fires when the [InAppBrowser] webview loads a resource.
///Event fired when the [InAppBrowser] webview loads a resource.
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewOptions.useOnLoadResource] and [InAppWebViewOptions.javaScriptEnabled] options to `true`.
void onLoadResource(LoadedResource resource) {
}
///Event fires when the [InAppBrowser] webview scrolls.
///Event fired when the [InAppBrowser] webview scrolls.
///
///[x] represents the current horizontal scroll origin in pixels.
///
......@@ -352,7 +352,7 @@ class InAppBrowser {
}
///Event fires when [InAppBrowser] recognizes and starts a downloadable file.
///Event fired when [InAppBrowser] recognizes and starts a downloadable file.
///
///[url] represents the url of the file.
///
......@@ -361,7 +361,7 @@ class InAppBrowser {
}
///Event fires when the [InAppBrowser] webview finds the `custom-scheme` while loading a resource. Here you can handle the url request and return a [CustomSchemeResponse] to load a specific resource encoded to `base64`.
///Event fired when the [InAppBrowser] webview finds the `custom-scheme` while loading a resource. Here you can handle the url request and return a [CustomSchemeResponse] to load a specific resource encoded to `base64`.
///
///[scheme] represents the scheme of the url.
///
......@@ -371,7 +371,7 @@ class InAppBrowser {
}
///Event fires when the [InAppBrowser] webview tries to open a link with `target="_blank"`.
///Event fired when the [InAppBrowser] webview tries to open a link with `target="_blank"`.
///
///[url] represents the url of the link.
///
......@@ -386,13 +386,13 @@ class InAppBrowser {
///
///[origin] represents the origin of the web content attempting to use the Geolocation API.
///
///**NOTE**: available only for Android.
///**NOTE**: available only on Android.
// ignore: missing_return
Future<GeolocationPermissionShowPromptResponse> onGeolocationPermissionsShowPrompt (String origin) {
}
///Event fires when javascript calls the `alert()` method to display an alert dialog.
///Event fired when javascript calls the `alert()` method to display an alert dialog.
///If [JsAlertResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog.
///
///[message] represents the message to be displayed in the alert dialog.
......@@ -401,7 +401,7 @@ class InAppBrowser {
}
///Event fires when javascript calls the `confirm()` method to display a confirm dialog.
///Event fired when javascript calls the `confirm()` method to display a confirm dialog.
///If [JsConfirmResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog.
///
///[message] represents the message to be displayed in the alert dialog.
......@@ -410,7 +410,7 @@ class InAppBrowser {
}
///Event fires when javascript calls the `prompt()` method to display a prompt dialog.
///Event fired when javascript calls the `prompt()` method to display a prompt dialog.
///If [JsPromptResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog.
///
///[message] represents the message to be displayed in the alert dialog.
......@@ -420,20 +420,20 @@ class InAppBrowser {
}
///Event fires when the webview notifies that a loading URL has been flagged by Safe Browsing.
///Event fired when the webview notifies that a loading URL has been flagged by Safe Browsing.
///The default behavior is to show an interstitial to the user, with the reporting checkbox visible.
///
///[url] represents the url of the request.
///
///[threatType] represents the reason the resource was caught by Safe Browsing, corresponding to a [SafeBrowsingThreat].
///
///**NOTE**: available only for Android.
///**NOTE**: available only on Android.
// ignore: missing_return
Future<SafeBrowsingResponse> onSafeBrowsingHit(String url, SafeBrowsingThreat threatType) {
}
///Event fires when the WebView received an HTTP authentication request. The default behavior is to cancel the request.
///Event fired when the WebView received an HTTP authentication request. The default behavior is to cancel the request.
///
///[challenge] contains data about host, port, protocol, realm, etc. as specified in the [HttpAuthChallenge].
// ignore: missing_return
......@@ -441,7 +441,7 @@ class InAppBrowser {
}
///Event fires when the WebView need to perform server trust authentication (certificate validation).
///Event fired when the WebView need to perform server trust authentication (certificate validation).
///The host application must return either [ServerTrustAuthResponse] instance with [ServerTrustAuthResponseAction.CANCEL] or [ServerTrustAuthResponseAction.PROCEED].
///
///[challenge] contains data about host, port, protocol, realm, etc. as specified in the [ServerTrustChallenge].
......@@ -506,7 +506,7 @@ class InAppBrowser {
}
///Event fired when an request is sent to a server through [Fetch API](https://developer.mozilla.org/it/docs/Web/API/Fetch_API).
///Event fired when a request is sent to a server through [Fetch API](https://developer.mozilla.org/it/docs/Web/API/Fetch_API).
///It gives the host application a chance to take control over the request before sending it.
///
///[fetchRequest] represents a resource request.
......
......@@ -23,19 +23,19 @@ const javaScriptHandlerForbiddenNames = ["onLoadResource", "shouldInterceptAjaxR
///Flutter Widget for adding an **inline native WebView** integrated in the flutter widget tree.
class InAppWebView extends StatefulWidget {
///Event fires when the [InAppWebView] is created.
///Event fired when the [InAppWebView] is created.
final void Function(InAppWebViewController controller) onWebViewCreated;
///Event fires when the [InAppWebView] starts to load an [url].
///Event fired when the [InAppWebView] starts to load an [url].
final void Function(InAppWebViewController controller, String url) onLoadStart;
///Event fires when the [InAppWebView] finishes loading an [url].
///Event fired when the [InAppWebView] finishes loading an [url].
final void Function(InAppWebViewController controller, String url) onLoadStop;
///Event fires when the [InAppWebView] encounters an error loading an [url].
///Event fired when the [InAppWebView] encounters an error loading an [url].
final void Function(InAppWebViewController controller, String url, int code, String message) onLoadError;
///Event fires when the [InAppWebView] main page receives an HTTP error.
///Event fired when the [InAppWebView] main page receives an HTTP error.
///
///[url] represents the url of the main page that received the HTTP error.
///
......@@ -46,10 +46,10 @@ class InAppWebView extends StatefulWidget {
///**NOTE**: available on Android 23+.
final void Function(InAppWebViewController controller, String url, int statusCode, String description) onLoadHttpError;
///Event fires when the current [progress] of loading a page is changed.
///Event fired when the current [progress] of loading a page is changed.
final void Function(InAppWebViewController controller, int progress) onProgressChanged;
///Event fires when the [InAppWebView] receives a [ConsoleMessage].
///Event fired when the [InAppWebView] receives a [ConsoleMessage].
final void Function(InAppWebViewController controller, ConsoleMessage consoleMessage) onConsoleMessage;
///Give the host application a chance to take control when a URL is about to be loaded in the current WebView.
......@@ -57,33 +57,33 @@ class InAppWebView extends StatefulWidget {
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewOptions.useShouldOverrideUrlLoading] option to `true`.
final void Function(InAppWebViewController controller, String url) shouldOverrideUrlLoading;
///Event fires when the [InAppWebView] loads a resource.
///Event fired when the [InAppWebView] loads a resource.
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewOptions.useOnLoadResource] and [InAppWebViewOptions.javaScriptEnabled] options to `true`.
final void Function(InAppWebViewController controller, LoadedResource resource) onLoadResource;
///Event fires when the [InAppWebView] scrolls.
///Event fired when the [InAppWebView] scrolls.
///
///[x] represents the current horizontal scroll origin in pixels.
///
///[y] represents the current vertical scroll origin in pixels.
final void Function(InAppWebViewController controller, int x, int y) onScrollChanged;
///Event fires when [InAppWebView] recognizes and starts a downloadable file.
///Event fired when [InAppWebView] recognizes and starts a downloadable file.
///
///[url] represents the url of the file.
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewOptions.useOnDownloadStart] option to `true`.
final void Function(InAppWebViewController controller, String url) onDownloadStart;
///Event fires when the [InAppWebView] finds the `custom-scheme` while loading a resource. Here you can handle the url request and return a [CustomSchemeResponse] to load a specific resource encoded to `base64`.
///Event fired when the [InAppWebView] finds the `custom-scheme` while loading a resource. Here you can handle the url request and return a [CustomSchemeResponse] to load a specific resource encoded to `base64`.
///
///[scheme] represents the scheme of the url.
///
///[url] represents the url of the request.
final Future<CustomSchemeResponse> Function(InAppWebViewController controller, String scheme, String url) onLoadResourceCustomScheme;
///Event fires when the [InAppWebView] tries to open a link with `target="_blank"`.
///Event fired when the [InAppWebView] tries to open a link with `target="_blank"`.
///
///[url] represents the url of the link.
///
......@@ -96,22 +96,22 @@ class InAppWebView extends StatefulWidget {
///
///[origin] represents the origin of the web content attempting to use the Geolocation API.
///
///**NOTE**: available only for Android.
///**NOTE**: available only on Android.
final Future<GeolocationPermissionShowPromptResponse> Function(InAppWebViewController controller, String origin) onGeolocationPermissionsShowPrompt;
///Event fires when javascript calls the `alert()` method to display an alert dialog.
///Event fired when javascript calls the `alert()` method to display an alert dialog.
///If [JsAlertResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog.
///
///[message] represents the message to be displayed in the alert dialog.
final Future<JsAlertResponse> Function(InAppWebViewController controller, String message) onJsAlert;
///Event fires when javascript calls the `confirm()` method to display a confirm dialog.
///Event fired when javascript calls the `confirm()` method to display a confirm dialog.
///If [JsConfirmResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog.
///
///[message] represents the message to be displayed in the alert dialog.
final Future<JsConfirmResponse> Function(InAppWebViewController controller, String message) onJsConfirm;
///Event fires when javascript calls the `prompt()` method to display a prompt dialog.
///Event fired when javascript calls the `prompt()` method to display a prompt dialog.
///If [JsPromptResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog.
///
///[message] represents the message to be displayed in the alert dialog.
......@@ -119,22 +119,22 @@ class InAppWebView extends StatefulWidget {
///[defaultValue] represents the default value displayed in the prompt dialog.
final Future<JsPromptResponse> Function(InAppWebViewController controller, String message, String defaultValue) onJsPrompt;
///Event fires when the webview notifies that a loading URL has been flagged by Safe Browsing.
///Event fired when the webview notifies that a loading URL has been flagged by Safe Browsing.
///The default behavior is to show an interstitial to the user, with the reporting checkbox visible.
///
///[url] represents the url of the request.
///
///[threatType] represents the reason the resource was caught by Safe Browsing, corresponding to a [SafeBrowsingThreat].
///
///**NOTE**: available only for Android.
///**NOTE**: available only on Android.
final Future<SafeBrowsingResponse> Function(InAppWebViewController controller, String url, SafeBrowsingThreat threatType) onSafeBrowsingHit;
///Event fires when the WebView received an HTTP authentication request. The default behavior is to cancel the request.
///Event fired when the WebView received an HTTP authentication request. The default behavior is to cancel the request.
///
///[challenge] contains data about host, port, protocol, realm, etc. as specified in the [HttpAuthChallenge].
final Future<HttpAuthResponse> Function(InAppWebViewController controller, HttpAuthChallenge challenge) onReceivedHttpAuthRequest;
///Event fires when the WebView need to perform server trust authentication (certificate validation).
///Event fired when the WebView need to perform server trust authentication (certificate validation).
///The host application must return either [ServerTrustAuthResponse] instance with [ServerTrustAuthResponseAction.CANCEL] or [ServerTrustAuthResponseAction.PROCEED].
///
///[challenge] contains data about host, port, protocol, realm, etc. as specified in the [ServerTrustChallenge].
......@@ -194,7 +194,7 @@ class InAppWebView extends StatefulWidget {
///Inside the `window.addEventListener("flutterInAppBrowserPlatformReady")` event, the ajax requests will be intercept for sure.
final Future<AjaxRequestAction> Function(InAppWebViewController controller, AjaxRequest ajaxRequest) onAjaxProgress;
///Event fired when an request is sent to a server through [Fetch API](https://developer.mozilla.org/it/docs/Web/API/Fetch_API).
///Event fired when a request is sent to a server through [Fetch API](https://developer.mozilla.org/it/docs/Web/API/Fetch_API).
///It gives the host application a chance to take control over the request before sending it.
///
///[fetchRequest] represents a resource request.
......@@ -979,7 +979,7 @@ class InAppWebViewController {
await _channel.invokeMethod('loadFile', args);
}
///Reloads the [InAppWebView].
///Reloads the WebView.
Future<void> reload() async {
Map<String, dynamic> args = <String, dynamic>{};
if (_inAppBrowserUuid != null && _inAppBrowser != null) {
......@@ -989,7 +989,7 @@ class InAppWebViewController {
await _channel.invokeMethod('reload', args);
}
///Goes back in the history of the [InAppWebView].
///Goes back in the history of the WebView.
Future<void> goBack() async {
Map<String, dynamic> args = <String, dynamic>{};
if (_inAppBrowserUuid != null && _inAppBrowser != null) {
......@@ -999,7 +999,7 @@ class InAppWebViewController {
await _channel.invokeMethod('goBack', args);
}
///Returns a boolean value indicating whether the [InAppWebView] can move backward.
///Returns a boolean value indicating whether the WebView can move backward.
Future<bool> canGoBack() async {
Map<String, dynamic> args = <String, dynamic>{};
if (_inAppBrowserUuid != null && _inAppBrowser != null) {
......@@ -1009,7 +1009,7 @@ class InAppWebViewController {
return await _channel.invokeMethod('canGoBack', args);
}
///Goes forward in the history of the [InAppWebView].
///Goes forward in the history of the WebView.
Future<void> goForward() async {
Map<String, dynamic> args = <String, dynamic>{};
if (_inAppBrowserUuid != null && _inAppBrowser != null) {
......@@ -1019,7 +1019,7 @@ class InAppWebViewController {
await _channel.invokeMethod('goForward', args);
}
///Returns a boolean value indicating whether the [InAppWebView] can move forward.
///Returns a boolean value indicating whether the WebView can move forward.
Future<bool> canGoForward() async {
Map<String, dynamic> args = <String, dynamic>{};
if (_inAppBrowserUuid != null && _inAppBrowser != null) {
......@@ -1148,7 +1148,7 @@ class InAppWebViewController {
///The `args` will be stringified automatically using `JSON.stringify(args)` method and then they will be decoded on the Dart side.
///
///In order to call `window.flutter_inappbrowser.callHandler(handlerName <String>, ...args)` properly, you need to wait and listen the JavaScript event `flutterInAppBrowserPlatformReady`.
///This event will be dispatch as soon as the platform (Android or iOS) is ready to handle the `callHandler` method.
///This event will be dispatched as soon as the platform (Android or iOS) is ready to handle the `callHandler` method.
///```javascript
/// window.addEventListener("flutterInAppBrowserPlatformReady", function(event) {
/// console.log("ready");
......@@ -1164,13 +1164,11 @@ class InAppWebViewController {
///<script>
/// window.addEventListener("flutterInAppBrowserPlatformReady", function(event) {
/// window.flutter_inappbrowser.callHandler('handlerFoo').then(function(result) {
/// console.log(result, typeof result);
/// console.log(JSON.stringify(result));
/// console.log(result);
/// });
///
/// window.flutter_inappbrowser.callHandler('handlerFooWithArgs', 1, true, ['bar', 5], {foo: 'baz'}).then(function(result) {
/// console.log(result, typeof result);
/// console.log(JSON.stringify(result));
/// console.log(result);
/// });
/// });
///</script>
......@@ -1284,7 +1282,7 @@ class InAppWebViewController {
///This should not be called if Safe Browsing has been disabled by manifest tag
///or [AndroidInAppWebViewOptions.safeBrowsingEnabled]. This prepares resources used for Safe Browsing.
///
///**NOTE**: available on Android 27+.
///**NOTE**: available only on Android 27+.
Future<bool> startSafeBrowsing() async {
Map<String, dynamic> args = <String, dynamic>{};
if (_inAppBrowserUuid != null && _inAppBrowser != null) {
......@@ -1308,7 +1306,7 @@ class InAppWebViewController {
///
///[hosts] represents the list of hosts. This value must never be null.
///
///**NOTE**: available on Android 27+.
///**NOTE**: available only on Android 27+.
Future<bool> setSafeBrowsingWhitelist({@required List<String> hosts}) async {
assert(hosts != null);
Map<String, dynamic> args = <String, dynamic>{};
......@@ -1322,7 +1320,7 @@ class InAppWebViewController {
///Returns a URL pointing to the privacy policy for Safe Browsing reporting. This value will never be `null`.
///
///**NOTE**: available on Android 27+.
///**NOTE**: available only on Android 27+.
Future<String> getSafeBrowsingPrivacyPolicyUrl() async {
Map<String, dynamic> args = <String, dynamic>{};
if (_inAppBrowserUuid != null && _inAppBrowser != null) {
......@@ -1332,7 +1330,7 @@ class InAppWebViewController {
return await _channel.invokeMethod('getSafeBrowsingPrivacyPolicyUrl', args);
}
///Clears all the webview's cache
///Clears all the webview's cache.
Future<void> clearCache() async {
Map<String, dynamic> args = <String, dynamic>{};
if (_inAppBrowserUuid != null && _inAppBrowser != null) {
......
......@@ -193,7 +193,7 @@ class InAppWebViewOptions implements WebViewOptions, BrowserOptions, AndroidOpti
///This class represents all the Android-only WebView options available.
class AndroidInAppWebViewOptions implements WebViewOptions, BrowserOptions, AndroidOptions {
///Sets the text zoom of the page in percent. The default is `100`.
///Sets the text zoom of the page in percent. The default value is `100`.
int textZoom;
///Set to `true` to have the session cookie cache cleared before the new window is opened.
bool clearSessionCache;
......@@ -278,7 +278,7 @@ class AndroidInAppWebViewOptions implements WebViewOptions, BrowserOptions, Andr
bool loadsImagesAutomatically;
///Sets the minimum logical font size. The default is `8`.
int minimumLogicalFontSize;
///Sets the initial scale for this WebView. 0 means default.The behavior for the default scale depends on the state of [useWideViewPort] and [loadWithOverviewMode].
///Sets the initial scale for this WebView. 0 means default. The behavior for the default scale depends on the state of [useWideViewPort] and [loadWithOverviewMode].
///If the content fits into the WebView control by width, then the zoom is set to 100%. For wide content, the behavior depends on the state of [loadWithOverviewMode].
///If its value is true, the content will be zoomed out to be fit by width into the WebView control, otherwise not.
///If initial scale is greater than 0, WebView starts with this value as initial scale.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment