|
@@ -1,8 +1,8 @@
|
|
|
import 'dart:async';
|
|
import 'dart:async';
|
|
|
import 'dart:ui';
|
|
import 'dart:ui';
|
|
|
|
|
|
|
|
-import 'package:flutter/services.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
+import 'package:flutter/services.dart';
|
|
|
|
|
|
|
|
const _kChannel = 'flutter_webview_plugin';
|
|
const _kChannel = 'flutter_webview_plugin';
|
|
|
|
|
|
|
@@ -38,7 +38,10 @@ class FlutterWebviewPlugin {
|
|
|
_onUrlChanged.add(call.arguments["url"]);
|
|
_onUrlChanged.add(call.arguments["url"]);
|
|
|
break;
|
|
break;
|
|
|
case "onState":
|
|
case "onState":
|
|
|
- _onStateChanged.add(WebViewStateChanged.fromMap(call.arguments));
|
|
|
|
|
|
|
+ _onStateChanged.add(
|
|
|
|
|
+ new WebViewStateChanged.fromMap(
|
|
|
|
|
+ new Map<String, dynamic>.from(call.arguments)),
|
|
|
|
|
+ );
|
|
|
break;
|
|
break;
|
|
|
case "onError":
|
|
case "onError":
|
|
|
_onError.add(WebViewError(call.arguments['code'], call.arguments['url']));
|
|
_onError.add(WebViewError(call.arguments['code'], call.arguments['url']));
|
|
@@ -73,6 +76,8 @@ class FlutterWebviewPlugin {
|
|
|
/// - [withLocalStorage] enable localStorage API on Webview
|
|
/// - [withLocalStorage] enable localStorage API on Webview
|
|
|
/// Currently Android only.
|
|
/// Currently Android only.
|
|
|
/// It is always enabled in UIWebView of iOS and can not be disabled.
|
|
/// It is always enabled in UIWebView of iOS and can not be disabled.
|
|
|
|
|
+ /// - [withLocalUrl]: allow url as a local path
|
|
|
|
|
+ /// Allow local files on iOs > 9.0
|
|
|
Future<Null> launch(String url,
|
|
Future<Null> launch(String url,
|
|
|
{bool withJavascript,
|
|
{bool withJavascript,
|
|
|
bool clearCache,
|
|
bool clearCache,
|
|
@@ -82,7 +87,8 @@ class FlutterWebviewPlugin {
|
|
|
Rect rect,
|
|
Rect rect,
|
|
|
String userAgent,
|
|
String userAgent,
|
|
|
bool withZoom,
|
|
bool withZoom,
|
|
|
- bool withLocalStorage}) async {
|
|
|
|
|
|
|
+ bool withLocalStorage,
|
|
|
|
|
+ bool withLocalUrl}) async {
|
|
|
Map<String, dynamic> args = {
|
|
Map<String, dynamic> args = {
|
|
|
"url": url,
|
|
"url": url,
|
|
|
"withJavascript": withJavascript ?? true,
|
|
"withJavascript": withJavascript ?? true,
|
|
@@ -92,7 +98,8 @@ class FlutterWebviewPlugin {
|
|
|
"enableAppScheme": enableAppScheme ?? true,
|
|
"enableAppScheme": enableAppScheme ?? true,
|
|
|
"userAgent": userAgent,
|
|
"userAgent": userAgent,
|
|
|
"withZoom": withZoom ?? false,
|
|
"withZoom": withZoom ?? false,
|
|
|
- "withLocalStorage": withLocalStorage ?? true
|
|
|
|
|
|
|
+ "withLocalStorage": withLocalStorage ?? true,
|
|
|
|
|
+ "withLocalUrl": withLocalUrl ?? false
|
|
|
};
|
|
};
|
|
|
if (rect != null) {
|
|
if (rect != null) {
|
|
|
args["rect"] = {
|
|
args["rect"] = {
|
|
@@ -115,6 +122,32 @@ class FlutterWebviewPlugin {
|
|
|
/// Will trigger the [onDestroy] event
|
|
/// Will trigger the [onDestroy] event
|
|
|
Future close() => _channel.invokeMethod("close");
|
|
Future close() => _channel.invokeMethod("close");
|
|
|
|
|
|
|
|
|
|
+ /// Reloads the WebView.
|
|
|
|
|
+ /// This is only available on Android for now.
|
|
|
|
|
+ Future reload() => _channel.invokeMethod("reload");
|
|
|
|
|
+
|
|
|
|
|
+ /// Navigates back on the Webview.
|
|
|
|
|
+ /// This is only available on Android for now.
|
|
|
|
|
+ Future goBack() => _channel.invokeMethod("back");
|
|
|
|
|
+
|
|
|
|
|
+ /// Navigates forward on the Webview.
|
|
|
|
|
+ /// This is only available on Android for now.
|
|
|
|
|
+ Future goForward() => _channel.invokeMethod("forward");
|
|
|
|
|
+
|
|
|
|
|
+ // Hides the webview
|
|
|
|
|
+ Future hide() => _channel.invokeMethod("hide");
|
|
|
|
|
+
|
|
|
|
|
+ // Shows the webview
|
|
|
|
|
+ Future show() => _channel.invokeMethod("show");
|
|
|
|
|
+
|
|
|
|
|
+ // Reload webview with a new url
|
|
|
|
|
+ Future reloadUrl(String url) async {
|
|
|
|
|
+ Map<String, dynamic> args = {
|
|
|
|
|
+ "url": url
|
|
|
|
|
+ };
|
|
|
|
|
+ await _channel.invokeMethod("reloadUrl", args);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/// Close all Streams
|
|
/// Close all Streams
|
|
|
void dispose() {
|
|
void dispose() {
|
|
|
_onDestroy.close();
|
|
_onDestroy.close();
|