diff --git a/.analysis_options b/.analysis_options
deleted file mode 100644
index 518eb901..00000000
--- a/.analysis_options
+++ /dev/null
@@ -1,2 +0,0 @@
-analyzer:
- strong-mode: true
\ No newline at end of file
diff --git a/.github/ISSUE_TEMPLATE/BUG.md b/.github/ISSUE_TEMPLATE/BUG.md
new file mode 100644
index 00000000..fe34c4b5
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/BUG.md
@@ -0,0 +1,73 @@
+---
+name: I have found out bug in plugin.
+about: You are writing an Flutter application with this webview plugin but the application is crashing
+ or throws an exception, a plugin is buggy, or something looks wrong.
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+
+
+## System info
+
+Issue occurs on: iOS / Android / both
+Plugin version: xxx
+Flutter doctor output:
+
+```
+paste it here...
+```
+
+## Steps to Reproduce
+
+
+
+1. ...
+2. ...
+3. ...
+
+## Logs
+
+
+
+```
+```
+
+
+
+```
+```
+
+
+
+```
+```
\ No newline at end of file
diff --git a/.github/ISSUE_TEMPLATE/SUPPORT.md b/.github/ISSUE_TEMPLATE/SUPPORT.md
new file mode 100644
index 00000000..80b8ac10
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/SUPPORT.md
@@ -0,0 +1,25 @@
+---
+name: I want help writing my application
+about: You have a question for how to achieve a particular effect, or you need help
+ with using a particular API.
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+
\ No newline at end of file
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644
index 00000000..ff69d16c
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,46 @@
+---
+name: Feature request
+about: Suggest a new idea for Flutter webview plugin.
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+
+
+## Use case
+
+
+
+## Proposal
+
+
\ No newline at end of file
diff --git a/.github/workflows/android_ut.yml b/.github/workflows/android_ut.yml
new file mode 100644
index 00000000..393daccb
--- /dev/null
+++ b/.github/workflows/android_ut.yml
@@ -0,0 +1,20 @@
+name: Android Unit Tests
+
+on: [push, pull_request]
+
+jobs:
+ test:
+ name: Linux Android Unit Tests
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v1
+ - uses: actions/setup-java@v1
+ with:
+ java-version: '12.x'
+ - uses: subosito/flutter-action@v1
+ with:
+ flutter-version: '1.7.8+hotfix.4'
+ - run: flutter doctor
+ - run: flutter pub get
+ - run: sh android_test.sh
diff --git a/.github/workflows/flutter_ut.yml b/.github/workflows/flutter_ut.yml
new file mode 100644
index 00000000..42d66d46
--- /dev/null
+++ b/.github/workflows/flutter_ut.yml
@@ -0,0 +1,20 @@
+name: Flutter Unit Tests
+
+on: [push, pull_request]
+
+jobs:
+ test:
+ name: Linux Flutter Unit Tests
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v1
+ - uses: actions/setup-java@v1
+ with:
+ java-version: '12.x'
+ - uses: subosito/flutter-action@v1
+ with:
+ flutter-version: '1.7.8+hotfix.4'
+ - run: flutter doctor
+ - run: flutter pub get
+ - run: flutter test
diff --git a/.gitignore b/.gitignore
index 731501dd..9f1cce46 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,11 +1,20 @@
.DS_Store
.atom/
.idea
+.vscode
.packages
.pub/
+.gradle/
build/
ios/.generated/
packages
pubspec.lock
example/ios/Podfile.lock
+**/Flutter/App.framework/
+**/Flutter/Flutter.framework/
+**/Flutter/Generated.xcconfig/
+**/Flutter/flutter_assets/
+example/ios/Flutter/flutter_export_environment.sh
+android/.project
+android/.settings/
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 49f348c4..7aaa09ae 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,142 @@
+# 0.3.9+1
+
+- Fixed error methods on iOS
+
+# 0.3.9
+
+- Fixed error methods on iOS
+- fixed build
+- fixed ios clean cookies
+- 4 Make plugin work in headless mode when extending FlutterApplication
+- added canGoBack and canGoForward methods
+
+# 0.3.8
+
+- Fix iOS local URL support (fixes #114)
+- bugfix: Added google() repository to allprojects to satisfy androidx build rules
+- fixed min sdk for android
+
+# 0.3.7
+
+- Added reloading url with headers
+- Added support for reloading url with headers
+
+# 0.3.6
+
+- Allow web contents debugging in Chrome
+- Android: allow geolocation and file chooser simultaneously
+- Add min sdk requirement and descriptions
+- fix bug android webview httperror exception
+- Exposes displayZoomControls, withOverviewMode and useWideViewPort settings for Android WebView
+
+# 0.3.5
+
+- Ability to choose from camera or gallery when using
+- Support for webview’s estimated loading progress #255
+- Fix back button handler to be compatible with the WillPopScope widget
+
+# 0.3.4
+
+- WebView always hidden on iOS
+
+# 0.3.3
+
+- BREAKING CHANGE - AndroidX support
+
+# 0.3.2
+
+- enable Javascript in iOS, support abort loading specific URLs
+- add resizeToAvoidBottomInset to WebviewScaffold; #301
+
+# 0.3.1
+
+- Add support for geolocation Android
+- fix No269: Can't load target="_blank" links on iOS
+- fix: reloadUrl will not return Future
+- Fix height of keyboard
+- Fix Hide/Show WebView
+- hotfix widget back to initialChild after webview is tapped on Android
+
+# 0.3.0
+
+- Fixes rect capture issue. Ensures WebView remains in the correct place on screen even when keyboard appears.
+- Fixed iOS crash issue with Flutter `>= 0.10.2`.
+- Added new `clearCookies` feature.
+- Added support for `hidden` and `initialChild` feature to show page loading view.
+- Added supportMultipleWindows: enables Multiple Window Support on Android.
+- Added appCacheEnabled: enables Application Caches API on Android.
+- Added allowFileURLs: allows `file://` local file URLs.
+- iOS Now supports: `reload`, `goBack`, and `goForward`.
+- iOS Bug fix `didFailNavigation` #77
+- Updated Android `compileSdkVersion` to `27` matching offical Flutter plugins.
+- Fixed Android `reloadUrl` so settings are not cleared.
+- Enabled compatible `Mixed Content Mode` on Android.
+
+# 0.2.1
+
+- Added webview scrolling listener
+- Added stopLoading() method
+
+# 0.2.0
+
+- update sdk
+- prevent negative webview height in scaffold
+- handle type error in getCookies
+- Support file upload via WebView on Android
+- fix WebviewScaffold crash on iOS
+- Scrollbar functionality to Web view
+- Add support of HTTP errors
+- Add headers when loading url
+
+# 0.1.6
+
+- fix onStateChanged
+- Taking safe areas into account for bottom bars
+- iOS
+ + withLocalUrl option for iOS > 9.0
+- Android
+ + add reload, goBack and foForward function
+
+# 0.1.5
+
+- iOS use WKWebView instead of UIWebView
+
+# 0.1.4
+
+- support localstorage for ANDROID
+
+# 0.1.3
+
+- support zoom in webview
+
+# 0.1.2
+
+- support bottomNavigationBar and persistentFooterButtons on webview scaffold
+
+# 0.1.1
+- support back button navigation for Android
+ + if cannot go back, it will trigger onDestroy
+- support preview dart2
+
+# 0.1.0+1
+
+- fix Android close webview
+
+# 0.1.0
+
+- iOS && Android:
+ - get cookies
+ - eval javascript
+ - user agent setting
+ - state change event
+ - embed in rectangle or fullscreen if null
+ - hidden webview
+
+- Android
+ - adding Activity in manifest is not needed anymore
+
+- Add `WebviewScaffold`
+
# 0.0.9
- Android: remove the need to use FlutterActivity as base activity
diff --git a/LICENSE b/LICENSE
index 86928f65..2fe58f3d 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,4 +1,4 @@
-// Copyright 2017 Your Company. All rights reserved.
+// Copyright 2017 Hadrien Lejard. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
@@ -10,7 +10,7 @@
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
-// * Neither the name of Your Company nor the names of its
+// * Neither the name of Hadrien Lejard nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
diff --git a/README.md b/README.md
index bccca4fc..7bb5abeb 100644
--- a/README.md
+++ b/README.md
@@ -1,58 +1,261 @@
-# flutter_webview_plugin
+[](https://github.com/fluttercommunity/community)
-Plugin that allow Flutter to communicate with a native WebView.
+# Flutter WebView Plugin
-***For Android, it will launch a new Activity inside the App with the Webview inside. Does not allow to integrate a Webview inside a Flutter Widget***
+[](https://pub.dartlang.org/packages/flutter_webview_plugin)
-***For IOS, it will launch a new UIViewController inside the App with the UIWebView inside. Does not allow to integrate a Webview inside a Flutter Widget***
+Plugin that allows Flutter to communicate with a native WebView.
- - [x] Android
- - [x] IOS
+**_Warning:_**
+The webview is not integrated in the widget tree, it is a native view on top of the flutter view.
+You won't be able see snackbars, dialogs, or other flutter widgets that would overlap with the region of the screen taken up by the webview.
+
+The getSafeAcceptedType() function is available only for minimum SDK of 21.
+eval() function only supports SDK of 19 or greater for evaluating Javascript.
## Getting Started
For help getting started with Flutter, view our online [documentation](http://flutter.io/).
+#### iOS
+
+In order for plugin to work correctly, you need to add new key to `ios/Runner/Info.plist`
+
+```xml
+NSAppTransportSecurity
+
+ NSAllowsArbitraryLoads
+
+ NSAllowsArbitraryLoadsInWebContent
+
+
+```
+
+`NSAllowsArbitraryLoadsInWebContent` is for iOS 10+ and `NSAllowsArbitraryLoads` for iOS 9.
+
+
### How it works
-#### Launch WebView with variable url
+#### Launch WebView Fullscreen with Flutter navigation
```dart
-void launchWebView(String url) sync {
- var flutterWebviewPlugin = new FlutterWebviewPlugin();
-
- flutterWebviewPlugin.launch(url);
-
- // Wait in this async function until destroy of WebView.
- await flutterWebviewPlugin.onDestroy.first;
-}
+new MaterialApp(
+ routes: {
+ "/": (_) => new WebviewScaffold(
+ url: "https://www.google.com",
+ appBar: new AppBar(
+ title: new Text("Widget webview"),
+ ),
+ ),
+ },
+ );
+```
+
+Optional parameters `hidden` and `initialChild` are available so that you can show something else while waiting for the page to load.
+If you set `hidden` to true it will show a default CircularProgressIndicator. If you additionally specify a Widget for initialChild
+you can have it display whatever you like till page-load.
+
+e.g. The following will show a read screen with the text 'waiting.....'.
+```dart
+return new MaterialApp(
+ title: 'Flutter WebView Demo',
+ theme: new ThemeData(
+ primarySwatch: Colors.blue,
+ ),
+ routes: {
+ '/': (_) => const MyHomePage(title: 'Flutter WebView Demo'),
+ '/widget': (_) => new WebviewScaffold(
+ url: selectedUrl,
+ appBar: new AppBar(
+ title: const Text('Widget webview'),
+ ),
+ withZoom: true,
+ withLocalStorage: true,
+ hidden: true,
+ initialChild: Container(
+ color: Colors.redAccent,
+ child: const Center(
+ child: Text('Waiting.....'),
+ ),
+ ),
+ ),
+ },
+);
+```
+
+`FlutterWebviewPlugin` provide a singleton instance linked to one unique webview,
+so you can take control of the webview from anywhere in the app
+
+listen for events
+
+```dart
+final flutterWebviewPlugin = new FlutterWebviewPlugin();
+
+flutterWebviewPlugin.onUrlChanged.listen((String url) {
+
+});
+```
+
+#### Listen for scroll event in webview
+
+```dart
+final flutterWebviewPlugin = new FlutterWebviewPlugin();
+flutterWebviewPlugin.onScrollYChanged.listen((double offsetY) { // latest offset value in vertical scroll
+ // compare vertical scroll changes here with old value
+});
+
+flutterWebviewPlugin.onScrollXChanged.listen((double offsetX) { // latest offset value in horizontal scroll
+ // compare horizontal scroll changes here with old value
+});
+
+````
+
+Note: Do note there is a slight difference is scroll distance between ios and android. Android scroll value difference tends to be larger than ios devices.
+
+
+#### Hidden WebView
+
+```dart
+final flutterWebviewPlugin = new FlutterWebviewPlugin();
+
+flutterWebviewPlugin.launch(url, hidden: true);
+```
+
+#### Close launched WebView
+
+```dart
+flutterWebviewPlugin.close();
```
-### Close launched WebView
+#### Webview inside custom Rectangle
```dart
-void launchWebViewAndCloseAfterWhile(String url) {
- var flutterWebviewPlugin = new FlutterWebviewPlugin();
-
- flutterWebviewPlugin.launch(url);
-
- // After 10 seconds.
- new Timer(const Duration(seconds: 10), () {
- // Close WebView.
- // This will also emit the onDestroy event.
- flutterWebviewPlugin.close();
+final flutterWebviewPlugin = new FlutterWebviewPlugin();
+
+flutterWebviewPlugin.launch(url,
+ fullScreen: false,
+ rect: new Rect.fromLTWH(
+ 0.0,
+ 0.0,
+ MediaQuery.of(context).size.width,
+ 300.0,
+ ),
+);
+```
+
+#### Injecting custom code into the webview
+Use `flutterWebviewPlugin.evalJavaScript(String code)`. This function must be run after the page has finished loading (i.e. listen to `onStateChanged` for events where state is `finishLoad`).
+
+If you have a large amount of JavaScript to embed, use an asset file. Add the asset file to `pubspec.yaml`, then call the function like:
+
+```dart
+Future loadJS(String name) async {
+ var givenJS = rootBundle.loadString('assets/$name.js');
+ return givenJS.then((String js) {
+ flutterWebViewPlugin.onStateChanged.listen((viewState) async {
+ if (viewState.type == WebViewState.finishLoad) {
+ flutterWebViewPlugin.evalJavascript(js);
+ }
+ });
});
}
```
-### Android
+### Accessing local files in the file system
+Set the `withLocalUrl` option to true in the launch function or in the Webview scaffold to enable support for local URLs.
-Add the Activity to you `AndroidManifest.xml`:
+Note that, on iOS, the `localUrlScope` option also needs to be set to a path to a directory. All files inside this folder (or subfolder) will be allowed access. If ommited, only the local file being opened will have access allowed, resulting in no subresources being loaded. This option is ignored on Android.
-```xml
-
+### Webview Events
+
+- `Stream` onDestroy
+- `Stream` onUrlChanged
+- `Stream` onStateChanged
+- `Stream` onScrollXChanged
+- `Stream` onScrollYChanged
+- `Stream` onError
+
+**_Don't forget to dispose webview_**
+`flutterWebviewPlugin.dispose()`
+
+### Webview Functions
+
+```dart
+Future launch(String url, {
+ Map headers: null,
+ bool withJavascript: true,
+ bool clearCache: false,
+ bool clearCookies: false,
+ bool hidden: false,
+ bool enableAppScheme: true,
+ Rect rect: null,
+ String userAgent: null,
+ bool withZoom: false,
+ bool withLocalStorage: true,
+ bool withLocalUrl: true,
+ String localUrlScope: null,
+ bool scrollBar: true,
+ bool supportMultipleWindows: false,
+ bool appCacheEnabled: false,
+ bool allowFileURLs: false,
+ bool displayZoomControls: false,
+ bool useWideViewPort: false,
+ bool withOverviewMode: false,
+});
+```
+
+```dart
+Future evalJavascript(String code);
+```
+
+```dart
+Future