|
@@ -19,7 +19,7 @@ class FlutterWebviewPlugin {
|
|
|
final _onDestroy = new StreamController<Null>.broadcast();
|
|
final _onDestroy = new StreamController<Null>.broadcast();
|
|
|
final _onUrlChanged = new StreamController<String>.broadcast();
|
|
final _onUrlChanged = new StreamController<String>.broadcast();
|
|
|
final _onStateChanged = new StreamController<WebViewStateChanged>.broadcast();
|
|
final _onStateChanged = new StreamController<WebViewStateChanged>.broadcast();
|
|
|
- final _onError = new StreamController<String>.broadcast();
|
|
|
|
|
|
|
+ final _onHttpError = new StreamController<WebViewHttpError>.broadcast();
|
|
|
|
|
|
|
|
static FlutterWebviewPlugin _instance;
|
|
static FlutterWebviewPlugin _instance;
|
|
|
|
|
|
|
@@ -43,8 +43,8 @@ class FlutterWebviewPlugin {
|
|
|
new Map<String, dynamic>.from(call.arguments)),
|
|
new Map<String, dynamic>.from(call.arguments)),
|
|
|
);
|
|
);
|
|
|
break;
|
|
break;
|
|
|
- case "onError":
|
|
|
|
|
- _onError.add(call.arguments);
|
|
|
|
|
|
|
+ case "onHttpError":
|
|
|
|
|
+ _onHttpError.add(WebViewHttpError(call.arguments['code'], call.arguments['url']));
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -60,6 +60,8 @@ class FlutterWebviewPlugin {
|
|
|
/// more detail than other events
|
|
/// more detail than other events
|
|
|
Stream<WebViewStateChanged> get onStateChanged => _onStateChanged.stream;
|
|
Stream<WebViewStateChanged> get onStateChanged => _onStateChanged.stream;
|
|
|
|
|
|
|
|
|
|
+ Stream<WebViewHttpError> get onHttpError => _onHttpError.stream;
|
|
|
|
|
+
|
|
|
/// Start the Webview with [url]
|
|
/// Start the Webview with [url]
|
|
|
/// - [withJavascript] enable Javascript or not for the Webview
|
|
/// - [withJavascript] enable Javascript or not for the Webview
|
|
|
/// iOS WebView: Not implemented yet
|
|
/// iOS WebView: Not implemented yet
|
|
@@ -162,7 +164,7 @@ class FlutterWebviewPlugin {
|
|
|
_onDestroy.close();
|
|
_onDestroy.close();
|
|
|
_onUrlChanged.close();
|
|
_onUrlChanged.close();
|
|
|
_onStateChanged.close();
|
|
_onStateChanged.close();
|
|
|
- _onError.close();
|
|
|
|
|
|
|
+ _onHttpError.close();
|
|
|
_instance = null;
|
|
_instance = null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -216,3 +218,10 @@ class WebViewStateChanged {
|
|
|
return new WebViewStateChanged(t, map["url"], map["navigationType"]);
|
|
return new WebViewStateChanged(t, map["url"], map["navigationType"]);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+class WebViewHttpError {
|
|
|
|
|
+ final String url;
|
|
|
|
|
+ final String code;
|
|
|
|
|
+
|
|
|
|
|
+ WebViewHttpError(this.code, this.url);
|
|
|
|
|
+}
|