Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ public void onMethodCall(MethodCall call, MethodChannel.Result result) {
case "resize":
resize(call, result);
break;
case "reload":
reload(call, result);
break;
case "back":
back(call, result);
break;
case "forward":
forward(call, result);
break;
default:
result.notImplemented();
break;
Expand Down Expand Up @@ -111,6 +120,31 @@ private void close(MethodCall call, MethodChannel.Result result) {
}
}

/**
* Navigates back on the Webview.
*/
private void back(MethodCall call, MethodChannel.Result result) {
if (webViewManager != null) {
webViewManager.back(call, result);
}
}
/**
* Navigates forward on the Webview.
*/
private void forward(MethodCall call, MethodChannel.Result result) {
if (webViewManager != null) {
webViewManager.forward(call, result);
}
}

/**
* Reloads the Webview.
*/
private void reload(MethodCall call, MethodChannel.Result result) {
if (webViewManager != null) {
webViewManager.reload(call, result);
}
}
private void eval(MethodCall call, final MethodChannel.Result result) {
if (webViewManager != null) {
webViewManager.eval(call, result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,44 @@ public void onReceiveValue(String value) {
}
});
}
/**
* Reloads the Webview.
*/
void reload(MethodCall call, MethodChannel.Result result) {
if (webView != null) {
webView.reload();
}
}
/**
* Navigates back on the Webview.
*/
void back(MethodCall call, MethodChannel.Result result) {
if (webView != null && webView.canGoBack()) {
webView.goBack();
}
}
/**
* Navigates forward on the Webview.
*/
void forward(MethodCall call, MethodChannel.Result result) {
if (webView != null && webView.canGoForward()) {
webView.goForward();
}
}

void resize(FrameLayout.LayoutParams params) {
webView.setLayoutParams(params);
}
/**
* Checks if going back on the Webview is possible.
*/
boolean canGoBack() {
return webView.canGoBack();
}
/**
* Checks if going forward on the Webview is possible.
*/
boolean canGoForward() {
return webView.canGoForward();
}
}
12 changes: 12 additions & 0 deletions lib/src/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ class FlutterWebviewPlugin {
/// Will trigger the [onDestroy] event
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");

/// Close all Streams
void dispose() {
_onDestroy.close();
Expand Down