├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── android ├── .gitignore ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src │ └── main │ ├── AndroidManifest.xml │ └── kotlin │ └── com │ └── apptreesoftware │ └── flutterwebview │ ├── FlutterWebViewPlugin.kt │ └── RedirectPolicy.kt ├── example ├── .gitignore ├── README.md ├── android.iml ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── apptreesoftware │ │ │ │ └── flutterwebviewexample │ │ │ │ └── MainActivity.kt │ │ │ └── res │ │ │ ├── drawable │ │ │ └── launch_background.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle ├── flutter_web_view_example.iml ├── flutter_web_view_example_android.iml ├── ios │ ├── .gitignore │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Podfile │ ├── Podfile.lock │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ └── contents.xcworkspacedata │ └── Runner │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ └── LaunchImage.imageset │ │ │ ├── Contents.json │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ └── README.md │ │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── main.m ├── lib │ └── main.dart └── pubspec.yaml ├── flutter_web_view.iml ├── flutter_web_view_android.iml ├── ios ├── .gitignore ├── Assets │ └── .gitkeep ├── Classes │ ├── FlutterWebViewPlugin.h │ ├── FlutterWebViewPlugin.m │ ├── RedirectPolicy.h │ ├── RedirectPolicy.m │ ├── WebViewController.h │ └── WebViewController.m └── flutter_web_view.podspec ├── lib └── flutter_web_view.dart ├── pubspec.lock └── pubspec.yaml /.gitignore: -------------------------------------------------------------------------------- 1 | .packages 2 | .dart_tool/ 3 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [0.0.1] - 09-25-17 2 | 3 | * Support for full screen web view 4 | * Supports nav bar with actions 5 | * Supports listening for redirect events 6 | * Control javascript and media playback support 7 | * Supports loading new pages ( post initialization ) 8 | * iOS & Android 9 | 10 | ## [0.0.2] - 11-07-17 11 | 12 | * Android back button support - https://github.com/apptreesoftware/flutter_webview/pull/5 13 | 14 | ## [0.0.4] - 11-12-18 15 | 16 | * Fix build errors after gradle update 17 | 18 | ## [0.0.5] - 11-12-18 19 | 20 | * Fix crash after upgrading to Flutter 0.11.3 21 | 22 | ## [0.0.6] - 03-04-19 23 | 24 | * Upgrade kotlin plugin version for compatibility with latest gradle 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2018 AppTree Software http://www.apptreesoftware.com 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Flutter Web View 2 | 3 | A web view plugin for Flutter. Works with iOS and Android 4 | 5 | Features 6 | 7 | - [x] Load Web Pages 8 | - [x] Reload/Load new pages while WebView still active 9 | - [x] Listen for Redirects 10 | - [x] Add buttons to a navigation bar 11 | - [x] Receive call backs for nav buttons pressed 12 | - [x] WebView loading callbacks 13 | - [x] Supports custom nav bar & button colors ( ios only for now ) 14 | - [ ] Advanced nav bar support ( position , enable, disable buttons ) 15 | - [ ] Support for nav bar icon buttons 16 | - [ ] WebView history support 17 | - [ ] Android back button customization 18 | - [ ] Built in controls for WebView navigation 19 | 20 | Feature requests welcome. 21 | 22 | 23 | ### Android Support 24 | To use on Android, make sure to add the the following in your AndroidManifest.xml 25 | 26 | ``` 27 | 28 | 29 | ``` 30 | 31 | ### Example Usage 32 | 33 | ``` 34 | flutterWebView.launch( 35 | "https://apptreesoftware.com", 36 | headers: { 37 | "X-SOME-HEADER": "MyCustomHeader", 38 | }, 39 | javaScriptEnabled: false, 40 | toolbarActions: [ 41 | new ToolbarAction("Dismiss", 1), 42 | new ToolbarAction("Reload", 2) 43 | ], 44 | barColor: Colors.green, 45 | tintColor: Colors.white); 46 | flutterWebView.onToolbarAction.listen((identifier) { 47 | switch (identifier) { 48 | case 1: 49 | flutterWebView.dismiss(); 50 | break; 51 | case 2: 52 | reload(); 53 | break; 54 | } 55 | }); 56 | flutterWebView.listenForRedirect("mobile://test.com", true); 57 | 58 | flutterWebView.onWebViewDidStartLoading.listen((url) { 59 | setState(() => _isLoading = true); 60 | }); 61 | flutterWebView.onWebViewDidLoad.listen((url) { 62 | setState(() => _isLoading = false); 63 | }); 64 | flutterWebView.onRedirect.listen((url) { 65 | flutterWebView.dismiss(); 66 | setState(() => _redirectedToUrl = url); 67 | }); 68 | ``` 69 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | group 'com.apptreesoftware.flutterwebview' 2 | version '1.0-SNAPSHOT' 3 | 4 | buildscript { 5 | repositories { 6 | google() 7 | jcenter() 8 | maven { 9 | url "https://maven.google.com" 10 | } 11 | } 12 | 13 | dependencies { 14 | classpath 'com.android.tools.build:gradle:3.2.0' 15 | classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.20' 16 | } 17 | } 18 | 19 | rootProject.allprojects { 20 | repositories { 21 | jcenter() 22 | maven { 23 | url "https://maven.google.com" 24 | } 25 | } 26 | } 27 | 28 | apply plugin: 'com.android.library' 29 | apply plugin: 'kotlin-android' 30 | 31 | android { 32 | compileSdkVersion 28 33 | buildToolsVersion '28.0.3' 34 | 35 | sourceSets { 36 | main.java.srcDirs += 'src/main/kotlin' 37 | } 38 | defaultConfig { 39 | minSdkVersion 16 40 | targetSdkVersion 28 41 | versionCode 1 42 | versionName "1.0" 43 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 44 | } 45 | lintOptions { 46 | disable 'InvalidPackage' 47 | } 48 | } 49 | 50 | dependencies { 51 | implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.51' 52 | } 53 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apptreesoftware/flutter_webview/46c1d84d86b76e22cb3ff565ba10ab1e3f703ff5/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Sep 27 04:37:04 PDT 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip 7 | -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'flutter_web_view' 2 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/apptreesoftware/flutterwebview/FlutterWebViewPlugin.kt: -------------------------------------------------------------------------------- 1 | package com.apptreesoftware.flutterwebview 2 | 3 | import android.app.Activity 4 | import android.content.Intent 5 | import android.graphics.Bitmap 6 | import android.os.Build 7 | import android.os.Bundle 8 | import android.view.Menu 9 | import android.view.MenuItem 10 | import android.webkit.* 11 | import io.flutter.app.FlutterActivity 12 | import io.flutter.plugin.common.MethodCall 13 | import io.flutter.plugin.common.MethodChannel 14 | import io.flutter.plugin.common.MethodChannel.MethodCallHandler 15 | import io.flutter.plugin.common.MethodChannel.Result 16 | import io.flutter.plugin.common.PluginRegistry.Registrar 17 | 18 | 19 | class FlutterWebViewPlugin(val activity: Activity) : MethodCallHandler { 20 | companion object { 21 | 22 | lateinit var channel: MethodChannel 23 | var currentActivity : WebViewActivity? = null 24 | 25 | var redirects = ArrayList() 26 | 27 | @JvmStatic 28 | fun registerWith(registrar: Registrar): Unit { 29 | channel = MethodChannel(registrar.messenger(), "plugins.apptreesoftware.com/web_view") 30 | val plugin = FlutterWebViewPlugin(registrar.activity()) 31 | channel.setMethodCallHandler(plugin) 32 | redirects.clear() 33 | } 34 | 35 | fun onLoadStarted(url: String) { 36 | channel.invokeMethod("onLoadEvent", 37 | mapOf("event" to "webViewDidStartLoad", "url" to url)) 38 | } 39 | 40 | fun onLoadCompleted(url: String) { 41 | channel.invokeMethod("onLoadEvent", 42 | mapOf("event" to "webViewDidLoad", "url" to url)) 43 | } 44 | 45 | fun onError(error: String) { 46 | channel.invokeMethod("onError", error) 47 | } 48 | 49 | fun onRedirect(url: String) { 50 | channel.invokeMethod("onRedirect", url) 51 | } 52 | 53 | fun onToolbarAction(actionId: Int) { 54 | channel.invokeMethod("onToolbarAction", actionId) 55 | } 56 | } 57 | 58 | override fun onMethodCall(call: MethodCall, result: Result): Unit { 59 | 60 | when (call.method) { 61 | "launch" -> { 62 | val actions: List>? = call.argument("actions") 63 | val actionsArray = ArrayList>() 64 | if (actions != null) { 65 | actionsArray.addAll(actions) 66 | } 67 | //val tintColor = call.argument("tint") 68 | //val barColor = call.argument("barTint") 69 | 70 | val url = call.argument("url") 71 | val javaScriptEnabled = call.argument("javaScriptEnabled") ?: false 72 | val inlineMediaEnabled = call.argument("inlineMediaEnabled") ?: false 73 | val clearCookies = call.argument("clearCookies") ?: false 74 | val headers = call.argument?>("headers") 75 | val hashMapHeaders = HashMap() 76 | if (headers != null) { 77 | hashMapHeaders.putAll(headers) 78 | } 79 | val intent = Intent(activity, WebViewActivity::class.java) 80 | intent.putExtra(WebViewActivity.EXTRA_URL, url) 81 | intent.putExtra(WebViewActivity.HEADERS, hashMapHeaders) 82 | intent.putExtra(WebViewActivity.ACTIONS, actionsArray) 83 | intent.putExtra(WebViewActivity.JAVASCRIPT_ENABLED, javaScriptEnabled) 84 | intent.putExtra(WebViewActivity.INLINE_MEDIA_ENABLED, inlineMediaEnabled) 85 | intent.putExtra(WebViewActivity.CLEAR_COOKIES, clearCookies) 86 | this.activity.startActivity(intent) 87 | result.success("") 88 | } 89 | "onRedirect" -> { 90 | val url = call.argument("url") ?: throw RuntimeException("url must be provided") 91 | val stopOnRedirect = call.argument("stopOnRedirect") ?: true 92 | val policy = RedirectPolicy(url, stopOnRedirect, MatchType.PREFIX) 93 | redirects.add(policy) 94 | result.success("") 95 | } 96 | "dismiss" -> { 97 | currentActivity?.finish() 98 | currentActivity = null 99 | } 100 | "load" -> { 101 | val url = call.argument("url") ?: throw RuntimeException("url must be provided") 102 | val headers = call.argument?>("headers") 103 | val hashMapHeaders = HashMap() 104 | if (headers != null) { 105 | hashMapHeaders.putAll(headers) 106 | } 107 | currentActivity?.load(url, hashMapHeaders) 108 | } 109 | else -> result.notImplemented() 110 | } 111 | } 112 | } 113 | 114 | class WebViewActivity : Activity() { 115 | 116 | companion object { 117 | val EXTRA_URL = "url" 118 | val ACTIONS = "actions" 119 | val HEADERS = "headers" 120 | val BAR_COLOR = "barColor" 121 | val INLINE_MEDIA_ENABLED = "inlineMediaEnabled" 122 | val JAVASCRIPT_ENABLED = "javaScriptEnabled" 123 | val CLEAR_COOKIES = "clearCookies" 124 | } 125 | 126 | lateinit var webView : WebView 127 | 128 | override fun onCreate(savedInstanceState: Bundle?) { 129 | super.onCreate(savedInstanceState) 130 | webView = WebView(this) 131 | title = "" 132 | setContentView(webView) 133 | webView.settings.javaScriptEnabled = intent.getBooleanExtra(JAVASCRIPT_ENABLED, false) 134 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { 135 | webView.settings.mediaPlaybackRequiresUserGesture = intent.getBooleanExtra( 136 | INLINE_MEDIA_ENABLED, false) 137 | } 138 | webView.webViewClient = WebClient() 139 | if (clearCookies) { 140 | clearCookies() 141 | } 142 | webView.loadUrl(url, headers) 143 | } 144 | 145 | override fun onResume() { 146 | FlutterWebViewPlugin.currentActivity = this 147 | super.onResume() 148 | } 149 | 150 | fun load(url : String, headers : HashMap) { 151 | intent.putExtra(WebViewActivity.EXTRA_URL, url) 152 | intent.putExtra(WebViewActivity.HEADERS, headers) 153 | webView.loadUrl(url, headers) 154 | } 155 | 156 | private fun clearCookies() { 157 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 158 | CookieManager.getInstance().removeAllCookies { } 159 | } else { 160 | CookieManager.getInstance().removeAllCookie() 161 | } 162 | } 163 | 164 | val url: String get() = intent.extras.getString(WebViewActivity.EXTRA_URL) 165 | val headers: HashMap 166 | get() = intent.getSerializableExtra(WebViewActivity.HEADERS) as HashMap 167 | val actions: ArrayList> 168 | get() = intent.getSerializableExtra(WebViewActivity.ACTIONS) as ArrayList> 169 | val clearCookies : Boolean get() = intent.getBooleanExtra(WebViewActivity.CLEAR_COOKIES, false) 170 | 171 | override fun onCreateOptionsMenu(menu: Menu): Boolean { 172 | for ((index, action) in actions.withIndex()) { 173 | menu.add(0, action["identifier"] as Int, index, action["title"] as String) 174 | } 175 | return super.onCreateOptionsMenu(menu) 176 | } 177 | 178 | override fun onOptionsItemSelected(item: MenuItem): Boolean { 179 | FlutterWebViewPlugin.onToolbarAction(item.itemId) 180 | return super.onOptionsItemSelected(item) 181 | } 182 | 183 | override fun onBackPressed() { 184 | if (webView.canGoBack()) { 185 | webView.goBack() 186 | } else { 187 | super.onBackPressed() 188 | } 189 | } 190 | } 191 | 192 | class WebClient : WebViewClient() { 193 | override fun onPageFinished(view: WebView?, url: String) { 194 | super.onPageFinished(view, url) 195 | FlutterWebViewPlugin.onLoadCompleted(url) 196 | } 197 | 198 | override fun onReceivedError(view: WebView?, request: WebResourceRequest?, 199 | error: WebResourceError?) { 200 | super.onReceivedError(view, request, error) 201 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { 202 | FlutterWebViewPlugin.onError( 203 | error?.description?.toString() ?: "An error occurred loading this page") 204 | } 205 | } 206 | 207 | override fun onReceivedError(view: WebView?, errorCode: Int, description: String?, 208 | failingUrl: String?) { 209 | super.onReceivedError(view, errorCode, description, failingUrl) 210 | FlutterWebViewPlugin.onError(description ?: "An error occurred loading this page") 211 | } 212 | 213 | override fun onPageStarted(view: WebView?, url: String, favicon: Bitmap?) { 214 | super.onPageStarted(view, url, favicon) 215 | FlutterWebViewPlugin.onLoadStarted(url) 216 | } 217 | 218 | override fun shouldOverrideUrlLoading(view: WebView, request: WebResourceRequest): Boolean { 219 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 220 | val url = request.url.toString() 221 | for (policy in FlutterWebViewPlugin.redirects) { 222 | if (policy.matchType == MatchType.PREFIX && url.startsWith(policy.url, 223 | ignoreCase = true)) { 224 | FlutterWebViewPlugin.onRedirect(url) 225 | return policy.stopOnRedirect 226 | } else if (policy.matchType == MatchType.SUFFIX && url.endsWith(policy.url, 227 | ignoreCase = true)) { 228 | FlutterWebViewPlugin.onRedirect(url) 229 | return policy.stopOnRedirect 230 | } else if (policy.matchType == MatchType.FULL_URL && url.equals(policy.url, 231 | ignoreCase = true)) { 232 | FlutterWebViewPlugin.onRedirect(url) 233 | return policy.stopOnRedirect 234 | } 235 | } 236 | } 237 | return false 238 | } 239 | 240 | override fun shouldOverrideUrlLoading(view: WebView?, url: String): Boolean { 241 | for (policy in FlutterWebViewPlugin.redirects) { 242 | if (policy.matchType == MatchType.PREFIX && url.startsWith(policy.url, 243 | ignoreCase = true)) { 244 | FlutterWebViewPlugin.onRedirect(url) 245 | return policy.stopOnRedirect 246 | } else if (policy.matchType == MatchType.SUFFIX && url.endsWith(policy.url, 247 | ignoreCase = true)) { 248 | FlutterWebViewPlugin.onRedirect(url) 249 | return policy.stopOnRedirect 250 | } else if (policy.matchType == MatchType.FULL_URL && url.equals(policy.url, 251 | ignoreCase = true)) { 252 | FlutterWebViewPlugin.onRedirect(url) 253 | return policy.stopOnRedirect 254 | } 255 | } 256 | return super.shouldOverrideUrlLoading(view, url) 257 | } 258 | } 259 | -------------------------------------------------------------------------------- /android/src/main/kotlin/com/apptreesoftware/flutterwebview/RedirectPolicy.kt: -------------------------------------------------------------------------------- 1 | package com.apptreesoftware.flutterwebview 2 | 3 | enum class MatchType { 4 | PREFIX, 5 | SUFFIX, 6 | FULL_URL 7 | } 8 | 9 | data class RedirectPolicy(val url : String, 10 | val stopOnRedirect : Boolean, 11 | val matchType : MatchType) -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .atom/ 3 | .idea 4 | .packages 5 | .pub/ 6 | build/ 7 | ios/.generated/ 8 | packages 9 | pubspec.lock 10 | .flutter-plugins 11 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # flutter_web_view_example 2 | 3 | Demonstrates how to use the flutter_web_view plugin. 4 | 5 | ## Getting Started 6 | 7 | For help getting started with Flutter, view our online 8 | [documentation](http://flutter.io/). 9 | -------------------------------------------------------------------------------- /example/android.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | GeneratedPluginRegistrant.java 10 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withInputStream { stream -> 5 | localProperties.load(stream) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | apply plugin: 'com.android.application' 15 | apply plugin: 'kotlin-android' 16 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 17 | 18 | android { 19 | compileSdkVersion 28 20 | buildToolsVersion '28.0.2' 21 | 22 | sourceSets { 23 | main.java.srcDirs += 'src/main/kotlin' 24 | } 25 | 26 | lintOptions { 27 | disable 'InvalidPackage' 28 | } 29 | 30 | defaultConfig { 31 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 32 | applicationId "com.apptreesoftware.flutterwebviewexample" 33 | minSdkVersion 16 34 | targetSdkVersion 28 35 | versionCode 1 36 | versionName "1.0" 37 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 38 | } 39 | 40 | buildTypes { 41 | release { 42 | // TODO: Add your own signing config for the release build. 43 | // Signing with the debug keys for now, so `flutter run --release` works. 44 | signingConfig signingConfigs.debug 45 | } 46 | } 47 | } 48 | 49 | flutter { 50 | source '../..' 51 | } 52 | 53 | dependencies { 54 | implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.51' 55 | } 56 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 15 | 19 | 26 | 30 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/com/apptreesoftware/flutterwebviewexample/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.apptreesoftware.flutterwebviewexample 2 | 3 | import android.os.Bundle 4 | 5 | import io.flutter.app.FlutterActivity 6 | import io.flutter.plugins.GeneratedPluginRegistrant 7 | 8 | class MainActivity(): FlutterActivity() { 9 | override fun onCreate(savedInstanceState: Bundle?) { 10 | super.onCreate(savedInstanceState) 11 | GeneratedPluginRegistrant.registerWith(this) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apptreesoftware/flutter_webview/46c1d84d86b76e22cb3ff565ba10ab1e3f703ff5/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apptreesoftware/flutter_webview/46c1d84d86b76e22cb3ff565ba10ab1e3f703ff5/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apptreesoftware/flutter_webview/46c1d84d86b76e22cb3ff565ba10ab1e3f703ff5/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apptreesoftware/flutter_webview/46c1d84d86b76e22cb3ff565ba10ab1e3f703ff5/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apptreesoftware/flutter_webview/46c1d84d86b76e22cb3ff565ba10ab1e3f703ff5/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | maven { 5 | url "https://maven.google.com" 6 | } 7 | } 8 | 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:3.1.4' 11 | classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.51' 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | maven { 19 | url "https://maven.google.com" 20 | } 21 | } 22 | } 23 | 24 | rootProject.buildDir = '../build' 25 | subprojects { 26 | project.buildDir = "${rootProject.buildDir}/${project.name}" 27 | project.evaluationDependsOn(':app') 28 | } 29 | 30 | task clean(type: Delete) { 31 | delete rootProject.buildDir 32 | } 33 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apptreesoftware/flutter_webview/46c1d84d86b76e22cb3ff565ba10ab1e3f703ff5/example/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip 7 | -------------------------------------------------------------------------------- /example/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /example/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() 4 | 5 | def plugins = new Properties() 6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') 7 | if (pluginsFile.exists()) { 8 | pluginsFile.withInputStream { stream -> plugins.load(stream) } 9 | } 10 | 11 | plugins.each { name, path -> 12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() 13 | include ":$name" 14 | project(":$name").projectDir = pluginDirectory 15 | } 16 | -------------------------------------------------------------------------------- /example/flutter_web_view_example.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /example/flutter_web_view_example_android.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vagrant/ 3 | .sconsign.dblite 4 | .svn/ 5 | 6 | .DS_Store 7 | *.swp 8 | profile 9 | 10 | DerivedData/ 11 | build/ 12 | GeneratedPluginRegistrant.h 13 | GeneratedPluginRegistrant.m 14 | 15 | *.pbxuser 16 | *.mode1v3 17 | *.mode2v3 18 | *.perspectivev3 19 | 20 | !default.pbxuser 21 | !default.mode1v3 22 | !default.mode2v3 23 | !default.perspectivev3 24 | 25 | xcuserdata 26 | 27 | *.moved-aside 28 | 29 | *.pyc 30 | *sync/ 31 | Icon? 32 | .tags* 33 | 34 | /Flutter/app.flx 35 | /Flutter/app.zip 36 | /Flutter/App.framework 37 | /Flutter/Flutter.framework 38 | /Flutter/Generated.xcconfig 39 | /ServiceDefinitions.json 40 | 41 | Pods/ 42 | -------------------------------------------------------------------------------- /example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | UIRequiredDeviceCapabilities 24 | 25 | arm64 26 | 27 | MinimumOSVersion 28 | 8.0 29 | 30 | 31 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | if ENV['FLUTTER_FRAMEWORK_DIR'] == nil 5 | abort('Please set FLUTTER_FRAMEWORK_DIR to the directory containing Flutter.framework') 6 | end 7 | 8 | target 'Runner' do 9 | # Pods for Runner 10 | 11 | # Flutter Pods 12 | pod 'Flutter', :path => ENV['FLUTTER_FRAMEWORK_DIR'] 13 | 14 | if File.exists? '../.flutter-plugins' 15 | flutter_root = File.expand_path('..') 16 | File.foreach('../.flutter-plugins') { |line| 17 | plugin = line.split(pattern='=') 18 | if plugin.length == 2 19 | name = plugin[0].strip() 20 | path = plugin[1].strip() 21 | resolved_path = File.expand_path("#{path}/ios", flutter_root) 22 | pod name, :path => resolved_path 23 | else 24 | puts "Invalid plugin specification: #{line}" 25 | end 26 | } 27 | end 28 | end 29 | 30 | post_install do |installer| 31 | installer.pods_project.targets.each do |target| 32 | target.build_configurations.each do |config| 33 | config.build_settings['ENABLE_BITCODE'] = 'NO' 34 | end 35 | end 36 | end 37 | -------------------------------------------------------------------------------- /example/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Flutter (1.0.0) 3 | - flutter_web_view (0.0.1): 4 | - Flutter 5 | 6 | DEPENDENCIES: 7 | - Flutter (from `/Users/matthew/flutter/bin/cache/artifacts/engine/ios`) 8 | - flutter_web_view (from `/Users/matthew/Projects/AppTree/plugins/flutter_web_view/ios`) 9 | 10 | EXTERNAL SOURCES: 11 | Flutter: 12 | :path: "/Users/matthew/flutter/bin/cache/artifacts/engine/ios" 13 | flutter_web_view: 14 | :path: "/Users/matthew/Projects/AppTree/plugins/flutter_web_view/ios" 15 | 16 | SPEC CHECKSUMS: 17 | Flutter: 9d0fac939486c9aba2809b7982dfdbb47a7b0296 18 | flutter_web_view: 6172ec2a6b4c7a33d840300a74354b913416782e 19 | 20 | PODFILE CHECKSUM: 351e02e34b831289961ec3558a535cbd2c4965d2 21 | 22 | COCOAPODS: 1.5.2 23 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1056D035E7426E1E008F1AF5 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A5F39B2FDBDA0571499183F5 /* libPods-Runner.a */; }; 11 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 12 | 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; }; 13 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 14 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; 15 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 16 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; 17 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 18 | 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; }; 19 | 9740EEB51CF90195004384FC /* Generated.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB31CF90195004384FC /* Generated.xcconfig */; }; 20 | 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; 21 | 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; 22 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 23 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 24 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 25 | /* End PBXBuildFile section */ 26 | 27 | /* Begin PBXCopyFilesBuildPhase section */ 28 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 29 | isa = PBXCopyFilesBuildPhase; 30 | buildActionMask = 2147483647; 31 | dstPath = ""; 32 | dstSubfolderSpec = 10; 33 | files = ( 34 | 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */, 35 | 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, 36 | ); 37 | name = "Embed Frameworks"; 38 | runOnlyForDeploymentPostprocessing = 0; 39 | }; 40 | /* End PBXCopyFilesBuildPhase section */ 41 | 42 | /* Begin PBXFileReference section */ 43 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 44 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 45 | 2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; }; 46 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 47 | 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; 48 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 49 | 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 50 | 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 51 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 52 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 53 | 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; 54 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 55 | 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 56 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 57 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 58 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 59 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 60 | A5F39B2FDBDA0571499183F5 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 61 | /* End PBXFileReference section */ 62 | 63 | /* Begin PBXFrameworksBuildPhase section */ 64 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 65 | isa = PBXFrameworksBuildPhase; 66 | buildActionMask = 2147483647; 67 | files = ( 68 | 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, 69 | 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, 70 | 1056D035E7426E1E008F1AF5 /* libPods-Runner.a in Frameworks */, 71 | ); 72 | runOnlyForDeploymentPostprocessing = 0; 73 | }; 74 | /* End PBXFrameworksBuildPhase section */ 75 | 76 | /* Begin PBXGroup section */ 77 | 2B37A3C8FD907493581E8404 /* Pods */ = { 78 | isa = PBXGroup; 79 | children = ( 80 | ); 81 | name = Pods; 82 | sourceTree = ""; 83 | }; 84 | 555BB41FF2F4B54EDA9D2FCD /* Frameworks */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | A5F39B2FDBDA0571499183F5 /* libPods-Runner.a */, 88 | ); 89 | name = Frameworks; 90 | sourceTree = ""; 91 | }; 92 | 9740EEB11CF90186004384FC /* Flutter */ = { 93 | isa = PBXGroup; 94 | children = ( 95 | 3B80C3931E831B6300D905FE /* App.framework */, 96 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 97 | 2D5378251FAA1A9400D5DBA9 /* flutter_assets */, 98 | 9740EEBA1CF902C7004384FC /* Flutter.framework */, 99 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 100 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 101 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 102 | ); 103 | name = Flutter; 104 | sourceTree = ""; 105 | }; 106 | 97C146E51CF9000F007C117D = { 107 | isa = PBXGroup; 108 | children = ( 109 | 9740EEB11CF90186004384FC /* Flutter */, 110 | 97C146F01CF9000F007C117D /* Runner */, 111 | 97C146EF1CF9000F007C117D /* Products */, 112 | 2B37A3C8FD907493581E8404 /* Pods */, 113 | 555BB41FF2F4B54EDA9D2FCD /* Frameworks */, 114 | ); 115 | sourceTree = ""; 116 | }; 117 | 97C146EF1CF9000F007C117D /* Products */ = { 118 | isa = PBXGroup; 119 | children = ( 120 | 97C146EE1CF9000F007C117D /* Runner.app */, 121 | ); 122 | name = Products; 123 | sourceTree = ""; 124 | }; 125 | 97C146F01CF9000F007C117D /* Runner */ = { 126 | isa = PBXGroup; 127 | children = ( 128 | 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */, 129 | 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */, 130 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 131 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 132 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 133 | 97C147021CF9000F007C117D /* Info.plist */, 134 | 97C146F11CF9000F007C117D /* Supporting Files */, 135 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 136 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 137 | ); 138 | path = Runner; 139 | sourceTree = ""; 140 | }; 141 | 97C146F11CF9000F007C117D /* Supporting Files */ = { 142 | isa = PBXGroup; 143 | children = ( 144 | 97C146F21CF9000F007C117D /* main.m */, 145 | ); 146 | name = "Supporting Files"; 147 | sourceTree = ""; 148 | }; 149 | /* End PBXGroup section */ 150 | 151 | /* Begin PBXNativeTarget section */ 152 | 97C146ED1CF9000F007C117D /* Runner */ = { 153 | isa = PBXNativeTarget; 154 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 155 | buildPhases = ( 156 | C48D34CA8A26C72043A4661C /* [CP] Check Pods Manifest.lock */, 157 | 9740EEB61CF901F6004384FC /* Run Script */, 158 | 97C146EA1CF9000F007C117D /* Sources */, 159 | 97C146EB1CF9000F007C117D /* Frameworks */, 160 | 97C146EC1CF9000F007C117D /* Resources */, 161 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 162 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 163 | 7EF08C0538D44C7C2FE2041D /* [CP] Embed Pods Frameworks */, 164 | ); 165 | buildRules = ( 166 | ); 167 | dependencies = ( 168 | ); 169 | name = Runner; 170 | productName = Runner; 171 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 172 | productType = "com.apple.product-type.application"; 173 | }; 174 | /* End PBXNativeTarget section */ 175 | 176 | /* Begin PBXProject section */ 177 | 97C146E61CF9000F007C117D /* Project object */ = { 178 | isa = PBXProject; 179 | attributes = { 180 | LastUpgradeCheck = 0830; 181 | ORGANIZATIONNAME = "The Chromium Authors"; 182 | TargetAttributes = { 183 | 97C146ED1CF9000F007C117D = { 184 | CreatedOnToolsVersion = 7.3.1; 185 | }; 186 | }; 187 | }; 188 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 189 | compatibilityVersion = "Xcode 3.2"; 190 | developmentRegion = English; 191 | hasScannedForEncodings = 0; 192 | knownRegions = ( 193 | en, 194 | Base, 195 | ); 196 | mainGroup = 97C146E51CF9000F007C117D; 197 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 198 | projectDirPath = ""; 199 | projectRoot = ""; 200 | targets = ( 201 | 97C146ED1CF9000F007C117D /* Runner */, 202 | ); 203 | }; 204 | /* End PBXProject section */ 205 | 206 | /* Begin PBXResourcesBuildPhase section */ 207 | 97C146EC1CF9000F007C117D /* Resources */ = { 208 | isa = PBXResourcesBuildPhase; 209 | buildActionMask = 2147483647; 210 | files = ( 211 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 212 | 9740EEB51CF90195004384FC /* Generated.xcconfig in Resources */, 213 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 214 | 2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */, 215 | 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */, 216 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 217 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 218 | ); 219 | runOnlyForDeploymentPostprocessing = 0; 220 | }; 221 | /* End PBXResourcesBuildPhase section */ 222 | 223 | /* Begin PBXShellScriptBuildPhase section */ 224 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 225 | isa = PBXShellScriptBuildPhase; 226 | buildActionMask = 2147483647; 227 | files = ( 228 | ); 229 | inputPaths = ( 230 | ); 231 | name = "Thin Binary"; 232 | outputPaths = ( 233 | ); 234 | runOnlyForDeploymentPostprocessing = 0; 235 | shellPath = /bin/sh; 236 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; 237 | }; 238 | 7EF08C0538D44C7C2FE2041D /* [CP] Embed Pods Frameworks */ = { 239 | isa = PBXShellScriptBuildPhase; 240 | buildActionMask = 2147483647; 241 | files = ( 242 | ); 243 | inputPaths = ( 244 | "${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", 245 | "${PODS_ROOT}/../../../../../../../flutter/bin/cache/artifacts/engine/ios/Flutter.framework", 246 | ); 247 | name = "[CP] Embed Pods Frameworks"; 248 | outputPaths = ( 249 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework", 250 | ); 251 | runOnlyForDeploymentPostprocessing = 0; 252 | shellPath = /bin/sh; 253 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; 254 | showEnvVarsInLog = 0; 255 | }; 256 | 9740EEB61CF901F6004384FC /* Run Script */ = { 257 | isa = PBXShellScriptBuildPhase; 258 | buildActionMask = 2147483647; 259 | files = ( 260 | ); 261 | inputPaths = ( 262 | ); 263 | name = "Run Script"; 264 | outputPaths = ( 265 | ); 266 | runOnlyForDeploymentPostprocessing = 0; 267 | shellPath = /bin/sh; 268 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 269 | }; 270 | C48D34CA8A26C72043A4661C /* [CP] Check Pods Manifest.lock */ = { 271 | isa = PBXShellScriptBuildPhase; 272 | buildActionMask = 2147483647; 273 | files = ( 274 | ); 275 | inputPaths = ( 276 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 277 | "${PODS_ROOT}/Manifest.lock", 278 | ); 279 | name = "[CP] Check Pods Manifest.lock"; 280 | outputPaths = ( 281 | "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", 282 | ); 283 | runOnlyForDeploymentPostprocessing = 0; 284 | shellPath = /bin/sh; 285 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 286 | showEnvVarsInLog = 0; 287 | }; 288 | /* End PBXShellScriptBuildPhase section */ 289 | 290 | /* Begin PBXSourcesBuildPhase section */ 291 | 97C146EA1CF9000F007C117D /* Sources */ = { 292 | isa = PBXSourcesBuildPhase; 293 | buildActionMask = 2147483647; 294 | files = ( 295 | 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */, 296 | 97C146F31CF9000F007C117D /* main.m in Sources */, 297 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 298 | ); 299 | runOnlyForDeploymentPostprocessing = 0; 300 | }; 301 | /* End PBXSourcesBuildPhase section */ 302 | 303 | /* Begin PBXVariantGroup section */ 304 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 305 | isa = PBXVariantGroup; 306 | children = ( 307 | 97C146FB1CF9000F007C117D /* Base */, 308 | ); 309 | name = Main.storyboard; 310 | sourceTree = ""; 311 | }; 312 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 313 | isa = PBXVariantGroup; 314 | children = ( 315 | 97C147001CF9000F007C117D /* Base */, 316 | ); 317 | name = LaunchScreen.storyboard; 318 | sourceTree = ""; 319 | }; 320 | /* End PBXVariantGroup section */ 321 | 322 | /* Begin XCBuildConfiguration section */ 323 | 97C147031CF9000F007C117D /* Debug */ = { 324 | isa = XCBuildConfiguration; 325 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 326 | buildSettings = { 327 | ALWAYS_SEARCH_USER_PATHS = NO; 328 | CLANG_ANALYZER_NONNULL = YES; 329 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 330 | CLANG_CXX_LIBRARY = "libc++"; 331 | CLANG_ENABLE_MODULES = YES; 332 | CLANG_ENABLE_OBJC_ARC = YES; 333 | CLANG_WARN_BOOL_CONVERSION = YES; 334 | CLANG_WARN_CONSTANT_CONVERSION = YES; 335 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 336 | CLANG_WARN_EMPTY_BODY = YES; 337 | CLANG_WARN_ENUM_CONVERSION = YES; 338 | CLANG_WARN_INFINITE_RECURSION = YES; 339 | CLANG_WARN_INT_CONVERSION = YES; 340 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 341 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 342 | CLANG_WARN_UNREACHABLE_CODE = YES; 343 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 344 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 345 | COPY_PHASE_STRIP = NO; 346 | DEBUG_INFORMATION_FORMAT = dwarf; 347 | ENABLE_STRICT_OBJC_MSGSEND = YES; 348 | ENABLE_TESTABILITY = YES; 349 | GCC_C_LANGUAGE_STANDARD = gnu99; 350 | GCC_DYNAMIC_NO_PIC = NO; 351 | GCC_NO_COMMON_BLOCKS = YES; 352 | GCC_OPTIMIZATION_LEVEL = 0; 353 | GCC_PREPROCESSOR_DEFINITIONS = ( 354 | "DEBUG=1", 355 | "$(inherited)", 356 | ); 357 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 358 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 359 | GCC_WARN_UNDECLARED_SELECTOR = YES; 360 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 361 | GCC_WARN_UNUSED_FUNCTION = YES; 362 | GCC_WARN_UNUSED_VARIABLE = YES; 363 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 364 | MTL_ENABLE_DEBUG_INFO = YES; 365 | ONLY_ACTIVE_ARCH = YES; 366 | SDKROOT = iphoneos; 367 | TARGETED_DEVICE_FAMILY = "1,2"; 368 | }; 369 | name = Debug; 370 | }; 371 | 97C147041CF9000F007C117D /* Release */ = { 372 | isa = XCBuildConfiguration; 373 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 374 | buildSettings = { 375 | ALWAYS_SEARCH_USER_PATHS = NO; 376 | CLANG_ANALYZER_NONNULL = YES; 377 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 378 | CLANG_CXX_LIBRARY = "libc++"; 379 | CLANG_ENABLE_MODULES = YES; 380 | CLANG_ENABLE_OBJC_ARC = YES; 381 | CLANG_WARN_BOOL_CONVERSION = YES; 382 | CLANG_WARN_CONSTANT_CONVERSION = YES; 383 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 384 | CLANG_WARN_EMPTY_BODY = YES; 385 | CLANG_WARN_ENUM_CONVERSION = YES; 386 | CLANG_WARN_INFINITE_RECURSION = YES; 387 | CLANG_WARN_INT_CONVERSION = YES; 388 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 389 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 390 | CLANG_WARN_UNREACHABLE_CODE = YES; 391 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 392 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 393 | COPY_PHASE_STRIP = NO; 394 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 395 | ENABLE_NS_ASSERTIONS = NO; 396 | ENABLE_STRICT_OBJC_MSGSEND = YES; 397 | GCC_C_LANGUAGE_STANDARD = gnu99; 398 | GCC_NO_COMMON_BLOCKS = YES; 399 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 400 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 401 | GCC_WARN_UNDECLARED_SELECTOR = YES; 402 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 403 | GCC_WARN_UNUSED_FUNCTION = YES; 404 | GCC_WARN_UNUSED_VARIABLE = YES; 405 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 406 | MTL_ENABLE_DEBUG_INFO = NO; 407 | SDKROOT = iphoneos; 408 | TARGETED_DEVICE_FAMILY = "1,2"; 409 | VALIDATE_PRODUCT = YES; 410 | }; 411 | name = Release; 412 | }; 413 | 97C147061CF9000F007C117D /* Debug */ = { 414 | isa = XCBuildConfiguration; 415 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 416 | buildSettings = { 417 | ARCHS = arm64; 418 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 419 | ENABLE_BITCODE = NO; 420 | FRAMEWORK_SEARCH_PATHS = ( 421 | "$(inherited)", 422 | "$(PROJECT_DIR)/Flutter", 423 | ); 424 | INFOPLIST_FILE = Runner/Info.plist; 425 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 426 | LIBRARY_SEARCH_PATHS = ( 427 | "$(inherited)", 428 | "$(PROJECT_DIR)/Flutter", 429 | ); 430 | PRODUCT_BUNDLE_IDENTIFIER = com.apptreesoftware.flutterWebViewExample; 431 | PRODUCT_NAME = "$(TARGET_NAME)"; 432 | }; 433 | name = Debug; 434 | }; 435 | 97C147071CF9000F007C117D /* Release */ = { 436 | isa = XCBuildConfiguration; 437 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 438 | buildSettings = { 439 | ARCHS = arm64; 440 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 441 | ENABLE_BITCODE = NO; 442 | FRAMEWORK_SEARCH_PATHS = ( 443 | "$(inherited)", 444 | "$(PROJECT_DIR)/Flutter", 445 | ); 446 | INFOPLIST_FILE = Runner/Info.plist; 447 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 448 | LIBRARY_SEARCH_PATHS = ( 449 | "$(inherited)", 450 | "$(PROJECT_DIR)/Flutter", 451 | ); 452 | PRODUCT_BUNDLE_IDENTIFIER = com.apptreesoftware.flutterWebViewExample; 453 | PRODUCT_NAME = "$(TARGET_NAME)"; 454 | }; 455 | name = Release; 456 | }; 457 | /* End XCBuildConfiguration section */ 458 | 459 | /* Begin XCConfigurationList section */ 460 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 461 | isa = XCConfigurationList; 462 | buildConfigurations = ( 463 | 97C147031CF9000F007C117D /* Debug */, 464 | 97C147041CF9000F007C117D /* Release */, 465 | ); 466 | defaultConfigurationIsVisible = 0; 467 | defaultConfigurationName = Release; 468 | }; 469 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 470 | isa = XCConfigurationList; 471 | buildConfigurations = ( 472 | 97C147061CF9000F007C117D /* Debug */, 473 | 97C147071CF9000F007C117D /* Release */, 474 | ); 475 | defaultConfigurationIsVisible = 0; 476 | defaultConfigurationName = Release; 477 | }; 478 | /* End XCConfigurationList section */ 479 | }; 480 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 481 | } 482 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface AppDelegate : FlutterAppDelegate 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #include "AppDelegate.h" 2 | #include "GeneratedPluginRegistrant.h" 3 | 4 | @implementation AppDelegate 5 | 6 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 7 | [GeneratedPluginRegistrant registerWithRegistry:self]; 8 | // Override point for customization after application launch. 9 | return [super application:application didFinishLaunchingWithOptions:launchOptions]; 10 | } 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | } 111 | ], 112 | "info" : { 113 | "version" : 1, 114 | "author" : "xcode" 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apptreesoftware/flutter_webview/46c1d84d86b76e22cb3ff565ba10ab1e3f703ff5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apptreesoftware/flutter_webview/46c1d84d86b76e22cb3ff565ba10ab1e3f703ff5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apptreesoftware/flutter_webview/46c1d84d86b76e22cb3ff565ba10ab1e3f703ff5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apptreesoftware/flutter_webview/46c1d84d86b76e22cb3ff565ba10ab1e3f703ff5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apptreesoftware/flutter_webview/46c1d84d86b76e22cb3ff565ba10ab1e3f703ff5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apptreesoftware/flutter_webview/46c1d84d86b76e22cb3ff565ba10ab1e3f703ff5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apptreesoftware/flutter_webview/46c1d84d86b76e22cb3ff565ba10ab1e3f703ff5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apptreesoftware/flutter_webview/46c1d84d86b76e22cb3ff565ba10ab1e3f703ff5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apptreesoftware/flutter_webview/46c1d84d86b76e22cb3ff565ba10ab1e3f703ff5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apptreesoftware/flutter_webview/46c1d84d86b76e22cb3ff565ba10ab1e3f703ff5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apptreesoftware/flutter_webview/46c1d84d86b76e22cb3ff565ba10ab1e3f703ff5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apptreesoftware/flutter_webview/46c1d84d86b76e22cb3ff565ba10ab1e3f703ff5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apptreesoftware/flutter_webview/46c1d84d86b76e22cb3ff565ba10ab1e3f703ff5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apptreesoftware/flutter_webview/46c1d84d86b76e22cb3ff565ba10ab1e3f703ff5/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apptreesoftware/flutter_webview/46c1d84d86b76e22cb3ff565ba10ab1e3f703ff5/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apptreesoftware/flutter_webview/46c1d84d86b76e22cb3ff565ba10ab1e3f703ff5/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apptreesoftware/flutter_webview/46c1d84d86b76e22cb3ff565ba10ab1e3f703ff5/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | flutter_web_view_example 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | NSAppTransportSecurity 28 | 29 | NSAllowsArbitraryLoads 30 | 31 | 32 | UIMainStoryboardFile 33 | Main 34 | UIRequiredDeviceCapabilities 35 | 36 | arm64 37 | 38 | UISupportedInterfaceOrientations 39 | 40 | UIInterfaceOrientationPortrait 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UISupportedInterfaceOrientations~ipad 45 | 46 | UIInterfaceOrientationPortrait 47 | UIInterfaceOrientationPortraitUpsideDown 48 | UIInterfaceOrientationLandscapeLeft 49 | UIInterfaceOrientationLandscapeRight 50 | 51 | UIViewControllerBasedStatusBarAppearance 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /example/ios/Runner/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import "AppDelegate.h" 4 | 5 | int main(int argc, char * argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_web_view/flutter_web_view.dart'; 3 | 4 | void main() { 5 | runApp(new MyApp()); 6 | } 7 | 8 | class MyApp extends StatefulWidget { 9 | @override 10 | _MyAppState createState() => new _MyAppState(); 11 | } 12 | 13 | class _MyAppState extends State { 14 | String _redirectedToUrl; 15 | FlutterWebView flutterWebView = new FlutterWebView(); 16 | bool _isLoading = false; 17 | 18 | @override 19 | initState() { 20 | super.initState(); 21 | } 22 | 23 | @override 24 | Widget build(BuildContext context) { 25 | Widget leading; 26 | if (_isLoading) { 27 | leading = new CircularProgressIndicator(); 28 | } 29 | var columnItems = [ 30 | new MaterialButton( 31 | onPressed: launchWebViewExample, child: new Text("Launch")) 32 | ]; 33 | if (_redirectedToUrl != null) { 34 | columnItems.add(new Text("Redirected to $_redirectedToUrl")); 35 | } 36 | var app = new MaterialApp( 37 | home: new Scaffold( 38 | appBar: new AppBar( 39 | leading: leading, 40 | ), 41 | body: new Column( 42 | children: columnItems, 43 | ), 44 | ), 45 | ); 46 | return app; 47 | } 48 | 49 | void launchWebViewExample() { 50 | if (flutterWebView.isLaunched) { 51 | return; 52 | } 53 | 54 | flutterWebView.launch("https://apptreesoftware.com", 55 | headers: { 56 | "X-SOME-HEADER": "MyCustomHeader", 57 | }, 58 | javaScriptEnabled: false, 59 | toolbarActions: [ 60 | new ToolbarAction("Dismiss", 1), 61 | new ToolbarAction("Reload", 2) 62 | ], 63 | barColor: Colors.green, 64 | tintColor: Colors.white); 65 | flutterWebView.onToolbarAction.listen((identifier) { 66 | switch (identifier) { 67 | case 1: 68 | flutterWebView.dismiss(); 69 | break; 70 | case 2: 71 | reload(); 72 | break; 73 | } 74 | }); 75 | flutterWebView.listenForRedirect("mobile://test.com", true); 76 | 77 | flutterWebView.onWebViewDidStartLoading.listen((url) { 78 | setState(() => _isLoading = true); 79 | }); 80 | flutterWebView.onWebViewDidLoad.listen((url) { 81 | setState(() => _isLoading = false); 82 | }); 83 | flutterWebView.onRedirect.listen((url) { 84 | flutterWebView.dismiss(); 85 | setState(() => _redirectedToUrl = url); 86 | }); 87 | } 88 | 89 | void reload() { 90 | flutterWebView.load( 91 | "https://google.com", 92 | headers: { 93 | "X-SOME-HEADER": "MyCustomHeader", 94 | }, 95 | ); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_web_view_example 2 | description: Demonstrates how to use the flutter_web_view plugin. 3 | 4 | dependencies: 5 | flutter: 6 | sdk: flutter 7 | 8 | dev_dependencies: 9 | flutter_test: 10 | sdk: flutter 11 | 12 | flutter_web_view: 13 | path: ../ 14 | 15 | # For information on the generic Dart part of this file, see the 16 | # following page: https://www.dartlang.org/tools/pub/pubspec 17 | 18 | # The following section is specific to Flutter. 19 | flutter: 20 | 21 | # The following line ensures that the Material Icons font is 22 | # included with your application, so that you can use the icons in 23 | # the Icons class. 24 | uses-material-design: true 25 | 26 | # To add assets to your application, add an assets section, like this: 27 | # assets: 28 | # - images/a_dot_burr.jpeg 29 | # - images/a_dot_ham.jpeg 30 | 31 | # An image asset can refer to one or more resolution-specific "variants", see 32 | # https://flutter.io/assets-and-images/. 33 | 34 | # For details regarding adding assets from package dependencies, see 35 | # https://flutter.io/assets-and-images/ 36 | 37 | # To add custom fonts to your application, add a fonts section here, 38 | # in this "flutter" section. Each entry in this list should have a 39 | # "family" key with the font family name, and a "fonts" key with a 40 | # list giving the asset and other descriptors for the font. For 41 | # example: 42 | # fonts: 43 | # - family: Schyler 44 | # fonts: 45 | # - asset: fonts/Schyler-Regular.ttf 46 | # - asset: fonts/Schyler-Italic.ttf 47 | # style: italic 48 | # - family: Trajan Pro 49 | # fonts: 50 | # - asset: fonts/TrajanPro.ttf 51 | # - asset: fonts/TrajanPro_Bold.ttf 52 | # weight: 700 53 | -------------------------------------------------------------------------------- /flutter_web_view.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /flutter_web_view_android.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .vagrant/ 3 | .sconsign.dblite 4 | .svn/ 5 | 6 | .DS_Store 7 | *.swp 8 | profile 9 | 10 | DerivedData/ 11 | build/ 12 | 13 | *.pbxuser 14 | *.mode1v3 15 | *.mode2v3 16 | *.perspectivev3 17 | 18 | !default.pbxuser 19 | !default.mode1v3 20 | !default.mode2v3 21 | !default.perspectivev3 22 | 23 | xcuserdata 24 | 25 | *.moved-aside 26 | 27 | *.pyc 28 | *sync/ 29 | Icon? 30 | .tags* 31 | 32 | -------------------------------------------------------------------------------- /ios/Assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apptreesoftware/flutter_webview/46c1d84d86b76e22cb3ff565ba10ab1e3f703ff5/ios/Assets/.gitkeep -------------------------------------------------------------------------------- /ios/Classes/FlutterWebViewPlugin.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class WebViewController; 4 | //@class EventStreamHandler; 5 | 6 | @interface FlutterWebViewPlugin : NSObject 7 | @property WebViewController *webViewController; 8 | @property UIViewController *hostViewController; 9 | @property FlutterMethodChannel *methodChannel; 10 | 11 | - (void)handleToolbar:(UIBarButtonItem *)item; 12 | 13 | - (void)handleWebViewLoadError:(NSString *)errorString; 14 | - (void)handleRedirect:(NSString *)url; 15 | - (void)handleWebViewDidStartLoad:(NSString *)url; 16 | - (void)handleWebViewDidFinishLoad:(NSString *)url; 17 | @end 18 | -------------------------------------------------------------------------------- /ios/Classes/FlutterWebViewPlugin.m: -------------------------------------------------------------------------------- 1 | #import "FlutterWebViewPlugin.h" 2 | #import "WebViewController.h" 3 | #import "RedirectPolicy.h" 4 | 5 | @implementation FlutterWebViewPlugin { 6 | } 7 | + (void)registerWithRegistrar:(NSObject *)registrar { 8 | FlutterMethodChannel *channel = [FlutterMethodChannel 9 | methodChannelWithName:@"plugins.apptreesoftware.com/web_view" 10 | binaryMessenger:[registrar messenger]]; 11 | UIViewController *viewController = [UIApplication sharedApplication].delegate.window.rootViewController; 12 | FlutterWebViewPlugin *instance = [[FlutterWebViewPlugin alloc] 13 | initWithViewController:viewController channel: channel]; 14 | [registrar addMethodCallDelegate:instance channel:channel]; 15 | } 16 | 17 | - (id)initWithViewController:(UIViewController *)viewController channel:(FlutterMethodChannel *)channel { 18 | self = [super init]; 19 | if (self) { 20 | self.hostViewController = viewController; 21 | self.methodChannel = channel; 22 | } 23 | return self; 24 | } 25 | 26 | - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result { 27 | if ([call.method isEqualToString:@"launch"]) { 28 | NSArray *actions = call.arguments[@"actions"]; 29 | NSString *tint = call.arguments[@"tint"]; 30 | UIColor *tintColor = [self parseNavColor:tint]; 31 | NSString *barTint = call.arguments[@"barTint"]; 32 | NSNumber *javaScriptEnabled = call.arguments[@"javaScriptEnabled"]; 33 | NSNumber *mediaPlaybackEnabled = call.arguments[@"inlineMediaEnabled"]; 34 | NSNumber *clearCookies = call.arguments[@"clearCookies"]; 35 | BOOL mediaPlayback = false; 36 | if (mediaPlaybackEnabled) { 37 | mediaPlayback = [mediaPlaybackEnabled boolValue]; 38 | } 39 | if (clearCookies.boolValue) { 40 | [[NSURLSession sharedSession] resetWithCompletionHandler:^{}]; 41 | } 42 | UIColor *barTintColor = [self parseNavColor:barTint]; 43 | NSMutableArray *buttons = [NSMutableArray array]; 44 | if (actions) { 45 | for (NSDictionary *action in actions) { 46 | UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithTitle:[action valueForKey:@"title"] 47 | style:UIBarButtonItemStylePlain 48 | target:self 49 | action:@selector(handleToolbar:)]; 50 | button.tag = [[action valueForKey:@"identifier"] intValue]; 51 | [buttons addObject:button]; 52 | } 53 | } 54 | self.webViewController = [[WebViewController alloc] initWithPlugin:self navItems:buttons allowMedia:mediaPlayback]; 55 | UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.webViewController]; 56 | [self.hostViewController presentViewController:navigationController animated:true completion:nil]; 57 | if (tintColor) { 58 | navigationController.navigationBar.tintColor = tintColor; 59 | } 60 | if (barTintColor) { 61 | navigationController.navigationBar.barTintColor = barTintColor; 62 | } 63 | [self performSelector:@selector(performLoad:) withObject:call.arguments afterDelay:0.4]; 64 | result(@""); 65 | return; 66 | } else if ([call.method isEqualToString:@"dismiss"]) { 67 | [self.webViewController dismissViewControllerAnimated:true completion:nil]; 68 | result(@""); 69 | } else if ([call.method isEqualToString:@"load"]) { 70 | [self performLoad:call.arguments]; 71 | result(@""); 72 | return; 73 | } else if ([call.method isEqualToString:@"back"]) { 74 | [self.webViewController.webView goBack]; 75 | result(@""); 76 | } else if ([call.method isEqualToString:@"forward"]) { 77 | [self.webViewController.webView goForward]; 78 | result(@""); 79 | } else if ([call.method isEqualToString:@"onRedirect"]) { 80 | NSString *url = call.arguments[@"url"]; 81 | NSNumber *stopOnRedirect = call.arguments[@"stopOnRedirect"]; 82 | RedirectPolicy *policy = [[RedirectPolicy alloc] initWithUrl:url matchType:PREFIX stopOnRedirect:stopOnRedirect.boolValue]; 83 | [self.webViewController listenForRedirect:policy]; 84 | result(@""); 85 | } 86 | result(FlutterMethodNotImplemented); 87 | } 88 | 89 | 90 | - (UIColor *)parseNavColor: (NSString *)colorString { 91 | if (!colorString) { 92 | return nil; 93 | } 94 | NSArray *components = [colorString componentsSeparatedByString:@","]; 95 | NSString *r = components[0]; 96 | NSString *g = components[1]; 97 | NSString *b = components[2]; 98 | 99 | return [UIColor colorWithRed:[r floatValue]/255.0 green:[g floatValue]/255.0 blue:[b floatValue]/255.0 alpha:1.0]; 100 | } 101 | 102 | - (void)performLoad:(NSDictionary *)params { 103 | NSString *urlString = params[@"url"]; 104 | NSDictionary *headers = params[@"headers"]; 105 | [self.webViewController load:urlString withHeaders:headers]; 106 | } 107 | 108 | - (void)handleToolbar:(UIBarButtonItem *)item { 109 | [self.methodChannel invokeMethod:@"onToolbarAction" arguments:@(item.tag)]; 110 | } 111 | 112 | - (void)handleWebViewLoadError:(NSString *)errorString { 113 | [self.methodChannel invokeMethod:@"onError" arguments:errorString]; 114 | } 115 | 116 | - (void)handleRedirect:(NSString *)url { 117 | [self.methodChannel invokeMethod:@"onRedirect" arguments:url]; 118 | } 119 | 120 | - (void)handleWebViewDidStartLoad:(NSString *)url { 121 | [self.methodChannel invokeMethod:@"onLoadEvent" arguments:@{@"event" : @"webViewDidStartLoad", @"url" : url}]; 122 | } 123 | 124 | - (void)handleWebViewDidFinishLoad:(NSString *)url { 125 | [self.methodChannel invokeMethod:@"onLoadEvent" arguments:@{@"event" : @"webViewDidLoad", @"url" : url}]; 126 | } 127 | 128 | @end 129 | 130 | -------------------------------------------------------------------------------- /ios/Classes/RedirectPolicy.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Matthew Smith on 9/17/17. 3 | // 4 | 5 | #import 6 | 7 | typedef enum matchType 8 | { 9 | PREFIX, 10 | SUFFIX, 11 | FULL_URL 12 | } MatchType; 13 | 14 | @interface RedirectPolicy : NSObject 15 | @property (nonatomic, retain) NSString *url; 16 | @property (nonatomic, assign) BOOL stopOnRedirect; 17 | @property (nonatomic, assign) MatchType matchType; 18 | 19 | - (id)initWithUrl:(NSString *)url matchType:(MatchType)matchType stopOnRedirect:(BOOL)stop; 20 | 21 | @end -------------------------------------------------------------------------------- /ios/Classes/RedirectPolicy.m: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Matthew Smith on 9/17/17. 3 | // 4 | 5 | #import "RedirectPolicy.h" 6 | 7 | 8 | @implementation RedirectPolicy { 9 | } 10 | 11 | - (id)initWithUrl:(NSString *)url matchType:(MatchType)matchType stopOnRedirect:(BOOL)stop { 12 | self = [super init]; 13 | if (self) { 14 | self.url = url; 15 | self.matchType = matchType; 16 | self.stopOnRedirect = stop; 17 | } 18 | return self; 19 | } 20 | @end -------------------------------------------------------------------------------- /ios/Classes/WebViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Matthew Smith on 9/17/17. 3 | // 4 | 5 | #import 6 | #import 7 | 8 | @class FlutterWebViewPlugin; 9 | @class RedirectPolicy; 10 | 11 | @interface WebViewController : UIViewController 12 | 13 | - (id)initWithPlugin:(FlutterWebViewPlugin *)plugin navItems:(NSArray *)navBarItems allowMedia:(BOOL)allowMedia; 14 | 15 | @property(nonatomic, weak) FlutterWebViewPlugin *plugin; 16 | @property(nonatomic, retain) UIWebView *webView; 17 | @property (nonatomic, retain) NSArray *navItems; 18 | @property (nonatomic, assign) BOOL allowMedia; 19 | 20 | - (void)load:(NSString *)urlString withHeaders:(NSDictionary *)headers; 21 | - (void)listenForRedirect:(RedirectPolicy *)redirect; 22 | 23 | @end -------------------------------------------------------------------------------- /ios/Classes/WebViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Matthew Smith on 9/17/17. 3 | // 4 | 5 | #import "WebViewController.h" 6 | #import "FlutterWebViewPlugin.h" 7 | #import "RedirectPolicy.h" 8 | 9 | @implementation WebViewController { 10 | NSMutableSet *redirects; 11 | 12 | } 13 | 14 | - (id)initWithPlugin:(FlutterWebViewPlugin *)plugin navItems:(NSArray *)navBarItems allowMedia:(BOOL)allowMedia { 15 | self = [super init]; 16 | if (self) { 17 | self.plugin = plugin; 18 | redirects = [NSMutableSet set]; 19 | self.navItems = navBarItems; 20 | } 21 | return self; 22 | } 23 | 24 | - (void)viewDidLoad { 25 | [super viewDidLoad]; 26 | self.navigationItem.rightBarButtonItems = self.navItems; 27 | self.webView = [[UIWebView alloc] initWithFrame:self.view.frame]; 28 | self.webView.delegate = self; 29 | self.webView.autoresizingMask = UIViewAutoresizingFlexibleWidth; 30 | self.webView.allowsInlineMediaPlayback = YES; 31 | [self.view addSubview:self.webView]; 32 | } 33 | 34 | - (void)load:(NSString *)urlString withHeaders:(NSDictionary *)headers { 35 | NSURL *url = [[NSURL alloc] initWithString:urlString]; 36 | if (!url) { 37 | return; 38 | } 39 | NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url]; 40 | if (headers) { 41 | NSEnumerator *keyE = headers.keyEnumerator; 42 | NSString *key = keyE.nextObject; 43 | while (key) { 44 | [request addValue:[headers valueForKey:key] forHTTPHeaderField:key]; 45 | key = keyE.nextObject; 46 | } 47 | } 48 | [_webView loadRequest:request]; 49 | } 50 | 51 | - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { 52 | NSString *url = [request URL].absoluteString; 53 | 54 | for (RedirectPolicy *policy in redirects) { 55 | if (policy.matchType == PREFIX && [url hasPrefix:policy.url]) { 56 | [self.plugin handleRedirect: request.URL.absoluteString]; 57 | return !policy.stopOnRedirect; 58 | } else if (policy.matchType == SUFFIX && [url hasSuffix:policy.url]) { 59 | [self.plugin handleRedirect:request.URL.absoluteString]; 60 | return !policy.stopOnRedirect; 61 | } else if (policy.matchType == FULL_URL && [url isEqualToString:policy.url]) { 62 | [self.plugin handleRedirect:request.URL.absoluteString]; 63 | return !policy.stopOnRedirect; 64 | } 65 | } 66 | return YES; 67 | } 68 | 69 | - (void)webViewDidStartLoad:(UIWebView *)webView { 70 | [self.plugin handleWebViewDidStartLoad:webView.request.URL.absoluteString]; 71 | } 72 | 73 | - (void)webViewDidFinishLoad:(UIWebView *)webView { 74 | [self.plugin handleWebViewDidFinishLoad:webView.request.URL.absoluteString]; 75 | } 76 | 77 | - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error { 78 | [self.plugin handleWebViewLoadError:error.localizedDescription]; 79 | } 80 | 81 | - (void)listenForRedirect:(RedirectPolicy *)redirect { 82 | [redirects addObject:redirect]; 83 | } 84 | 85 | @end 86 | -------------------------------------------------------------------------------- /ios/flutter_web_view.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html 3 | # 4 | Pod::Spec.new do |s| 5 | s.name = 'flutter_web_view' 6 | s.version = '0.0.1' 7 | s.summary = 'A web view plugin for Flutter. Works with iOS and Android' 8 | s.description = <<-DESC 9 | A web view plugin for Flutter. Works with iOS and Android 10 | DESC 11 | s.homepage = 'http://example.com' 12 | s.license = { :file => '../LICENSE' } 13 | s.author = { 'Your Company' => 'email@example.com' } 14 | s.source = { :path => '.' } 15 | s.source_files = 'Classes/**/*' 16 | s.public_header_files = 'Classes/**/*.h' 17 | s.dependency 'Flutter' 18 | 19 | s.ios.deployment_target = '8.0' 20 | end 21 | 22 | -------------------------------------------------------------------------------- /lib/flutter_web_view.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:ui'; 3 | 4 | import 'package:flutter/services.dart'; 5 | 6 | class FlutterWebView { 7 | static const MethodChannel _channel = 8 | const MethodChannel('plugins.apptreesoftware.com/web_view'); 9 | bool _launched = false; 10 | bool get isLaunched => _launched; 11 | 12 | StreamController _redirectStreamController = 13 | new StreamController.broadcast(); 14 | StreamController _errorStreamController = 15 | new StreamController.broadcast(); 16 | StreamController> _loadEventStreamController = 17 | new StreamController.broadcast(); 18 | StreamController _toolbarActionStreamController = 19 | new StreamController.broadcast(); 20 | 21 | void launch( 22 | String url, { 23 | Map headers, 24 | bool javaScriptEnabled, 25 | bool inlineMediaEnabled, 26 | List toolbarActions, 27 | Color tintColor, 28 | Color barColor, 29 | bool clearCookies = false, 30 | }) { 31 | _channel.setMethodCallHandler(_handlePlatformMessages); 32 | Map params = {"url": url}; 33 | _launched = true; 34 | if (headers != null) { 35 | params["headers"] = headers; 36 | } 37 | List actions = []; 38 | if (toolbarActions != null) { 39 | actions = toolbarActions.map((t) => t.toMap).toList(); 40 | } 41 | params["actions"] = actions; 42 | if (tintColor != null) { 43 | params["tint"] = "${tintColor.red},${tintColor.green},${tintColor.blue}"; 44 | } 45 | if (barColor != null) { 46 | params["barTint"] = "${barColor.red},${barColor.green},${barColor.blue}"; 47 | } 48 | if (javaScriptEnabled != null) { 49 | params["javaScriptEnabled"] = javaScriptEnabled; 50 | } 51 | if (inlineMediaEnabled != null) { 52 | params["inlineMediaEnabled"] = inlineMediaEnabled; 53 | } 54 | if (clearCookies) { 55 | params["clearCookies"] = clearCookies; 56 | } 57 | _channel.invokeMethod('launch', params); 58 | } 59 | 60 | void dismiss() { 61 | _launched = false; 62 | _channel.invokeMethod('dismiss'); 63 | } 64 | 65 | void load(String url, {Map headers}) { 66 | Map params = {"url": url}; 67 | if (headers != null) { 68 | params["headers"] = headers; 69 | } 70 | _channel.invokeMethod('load', params); 71 | } 72 | 73 | void listenForRedirect(String url, bool stopLoadOnRedirect) { 74 | _channel.invokeMethod( 75 | 'onRedirect', {"url": url, "stopOnRedirect": stopLoadOnRedirect}); 76 | } 77 | 78 | Stream get onRedirect => _redirectStreamController.stream; 79 | 80 | Stream get onToolbarAction => _toolbarActionStreamController.stream; 81 | 82 | Stream get onLoadError => _errorStreamController.stream; 83 | 84 | Stream get onWebViewDidStartLoading => 85 | _loadEventStreamController.stream 86 | .where((map) => map['event'] == "webViewDidStartLoad") 87 | .map((map) => map['url']); 88 | 89 | Stream get onWebViewDidLoad => _loadEventStreamController.stream 90 | .where((map) => map['event'] == "webViewDidLoad") 91 | .map((map) => map['url']); 92 | 93 | //Platform method handling 94 | 95 | Future _handlePlatformMessages(MethodCall call) async { 96 | switch (call.method) { 97 | case "onError": 98 | _errorStreamController.add(call.arguments); 99 | break; 100 | case "onLoadEvent": 101 | _loadEventStreamController.add(call.arguments); 102 | break; 103 | case "onToolbarAction": 104 | _toolbarActionStreamController.add(call.arguments); 105 | break; 106 | case "onRedirect": 107 | _redirectStreamController.add(call.arguments); 108 | break; 109 | default: 110 | break; 111 | } 112 | } 113 | } 114 | 115 | class ToolbarAction { 116 | final String title; 117 | final int identifier; 118 | 119 | /// Show the button in the toolbar only if there is room. 120 | /// DEFAULTS to false 121 | /// Only works on Android 122 | bool showIfRoom = false; 123 | 124 | ToolbarAction(this.title, this.identifier); 125 | 126 | Map get toMap => {"title": title, "identifier": identifier}; 127 | } 128 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://www.dartlang.org/tools/pub/glossary#lockfile 3 | packages: 4 | collection: 5 | dependency: transitive 6 | description: 7 | name: collection 8 | url: "https://pub.dartlang.org" 9 | source: hosted 10 | version: "1.14.11" 11 | flutter: 12 | dependency: "direct main" 13 | description: flutter 14 | source: sdk 15 | version: "0.0.0" 16 | meta: 17 | dependency: transitive 18 | description: 19 | name: meta 20 | url: "https://pub.dartlang.org" 21 | source: hosted 22 | version: "1.1.6" 23 | sky_engine: 24 | dependency: transitive 25 | description: flutter 26 | source: sdk 27 | version: "0.0.99" 28 | typed_data: 29 | dependency: transitive 30 | description: 31 | name: typed_data 32 | url: "https://pub.dartlang.org" 33 | source: hosted 34 | version: "1.1.6" 35 | vector_math: 36 | dependency: transitive 37 | description: 38 | name: vector_math 39 | url: "https://pub.dartlang.org" 40 | source: hosted 41 | version: "2.0.8" 42 | sdks: 43 | dart: ">=2.0.0 <3.0.0" 44 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_web_view 2 | description: A native WebView plugin for Flutter with Nav Bar support. Works with iOS and Android 3 | version: 0.0.6 4 | author: Matthew Smith 5 | homepage: https://github.com/apptreesoftware/flutter_webview 6 | 7 | environment: 8 | sdk: ">=2.0.0 <3.0.0" 9 | 10 | flutter: 11 | plugin: 12 | androidPackage: com.apptreesoftware.flutterwebview 13 | pluginClass: FlutterWebViewPlugin 14 | 15 | dependencies: 16 | flutter: 17 | sdk: flutter --------------------------------------------------------------------------------